Sha256: a43f114e0ed4dfee544caaf7095665870d9a1f43057ad08cd9714e5f9b009864
Contents?: true
Size: 716 Bytes
Versions: 4
Compression:
Stored size: 716 Bytes
Contents
module NightcrawlerSwift class Upload < Command def execute path, file, opts = {} body = file.read headers = {etag: etag(body), content_type: content_type(file)} max_age = opts[:max_age] || options.max_age headers.merge!(cache_control: "public, max-age=#{max_age}", expires: expires(max_age)) if max_age response = put "#{connection.upload_url}/#{path}", body: body, headers: headers [200, 201].include?(response.code) end private def content_type file MultiMime.by_file(file).content_type end def etag content Digest::MD5.hexdigest(content) end def expires max_age CGI.rfc1123_date(Time.now + max_age) end end end
Version data entries
4 entries across 4 versions & 1 rubygems