Sha256: 54b195f024adde0283e173b52395b3c5325140335460303d09097d3fbee6deac
Contents?: true
Size: 663 Bytes
Versions: 1
Compression:
Stored size: 663 Bytes
Contents
module NightcrawlerSwift class Upload < Command def execute path, file content = file.read headers = {etag: etag(content), content_type: content_type(file)} headers.merge!(cache_control: "max-age=#{options.max_age}") if options.max_age response = put "#{connection.upload_url}/#{path}", body: content, headers: headers [200, 201].include?(response.code) rescue RestClient::UnprocessableEntity => e raise Exceptions::ValidationError.new(e) end private def content_type file MultiMime.by_file(file).content_type end def etag content Digest::MD5.hexdigest(content) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nightcrawler_swift-0.4.0 | lib/nightcrawler_swift/commands/upload.rb |