Upload the gziped file to S3 with public_read access control
moduleS3Utility class << self # @return [String] S3 URL defupload_by_url(from_url:, object_key:) content = open(from_url).read fail "fail to get url: #{from_url}"if content.blank?
temp = Tempfile.new.tap do|t| t.binmode t.write(_gzip(content)) t.close end
obj = _bucket.object(object_key) result = obj.upload_file(temp.path, acl:'public-read', content_encoding:'gzip') fail "fail to upload url: #{from_url}, object_key: #{object_key}"unless result _url(object_key) rescue => e Airbrake.notify(e) nil end
private
def_url(object_key) "https://#{ENV['AMAZON_AWS_S3_BUCKET_NAME']}.s3-ap-northeast-1.amazonaws.com/#{object_key}" end
VULTR provides high performance cloud compute environment for you.
Vultr has 15 data-centers strategically placed around the globe, you can use a VPS with 512 MB memory for just $ 2.5 / month ($ 0.004 / hour).
In addition, Vultr is up to 4 times faster than the competition, so please check it => Check Benchmark Results!!