4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/nightcrawler_swift/commands/upload.rb', line 4
def execute path, file, opts = {}
if path.nil? or path.empty?
raise Exceptions::ValidationError.new "Upload command requires a path parameter"
end
body = file.read
= {etag: etag(body), content_type: content_type(file)}
max_age = opts[:max_age] || options.max_age
.merge!(cache_control: "public, max-age=#{max_age}") if max_age
expires = opts[:expires]
.merge!(expires: CGI.rfc1123_date(expires)) if expires
content_encoding = opts[:content_encoding] || options.content_encoding
.merge!(content_encoding: content_encoding.to_s) if content_encoding
= opts[:custom_headers]
.merge!() if
response = put "#{connection.upload_url}/#{path}", body: body, headers:
response.code >= 200 && response.code < 300
end
|