chore: Add down gem for Local file downloads (#2765)

- Add down gem to handle downloading files to host machine
- Remove the LocalResource class
- Introduce max limit for contact avatars send via SDK
This commit is contained in:
Sojan Jose
2021-08-11 16:40:28 +05:30
committed by GitHub
parent 29f54c1f26
commit 8daf1fe033
11 changed files with 47 additions and 93 deletions

View File

@@ -45,8 +45,10 @@ class ContactIpLookupJob < ApplicationJob
def setup_vendor_db
base_url = 'https://download.maxmind.com/app/geoip_download'
source = URI.parse("#{base_url}?edition_id=GeoLite2-City&suffix=tar.gz&license_key=#{ENV['IP_LOOKUP_API_KEY']}").open
tar_extract = Gem::Package::TarReader.new(Zlib::GzipReader.open(source))
source_file = Down.download(
"#{base_url}?edition_id=GeoLite2-City&suffix=tar.gz&license_key=#{ENV['IP_LOOKUP_API_KEY']}"
)
tar_extract = Gem::Package::TarReader.new(Zlib::GzipReader.open(source_file))
tar_extract.rewind
tar_extract.each do |entry|