Sha256: 860095b34892dfa537337f63f33dd3879081b20bfdee757e4150da27cf6a5474
Contents?: true
Size: 553 Bytes
Versions: 1
Compression:
Stored size: 553 Bytes
Contents
require 'digest' module NightcrawlerSwift class Upload < Command def execute path, file content_type = MultiMime.by_file(file).content_type content = file.read etag = '"%s"' % Digest::MD5.new.update(content).hexdigest headers = {etag: etag, content_type: content_type} headers.merge!({cache_control: "max-age=#{connection.opts.max_age}"}) if connection.opts.max_age response = put "#{connection.upload_url}/#{path}", body: content, headers: headers [200, 201].include?(response.code) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nightcrawler_swift-0.3.0 | lib/nightcrawler_swift/upload.rb |