1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Merge pull request #1662 from snoopie/master

Allow passing Content-Disposition header when saving file into Rackspace cloud
This commit is contained in:
Kyle Rames 2013-03-13 08:09:04 -07:00
commit 6988718ab7
2 changed files with 13 additions and 1 deletions

View file

@ -19,6 +19,8 @@ module Fog
# @see http://www.iana.org/assignments/media-types # @see http://www.iana.org/assignments/media-types
attribute :content_type, :aliases => ['content_type', 'Content-Type'] attribute :content_type, :aliases => ['content_type', 'Content-Type']
attribute :content_disposition, :aliases => 'Content-Disposition'
# @!attribute [rw] etag # @!attribute [rw] etag
# The MD5 checksum of file. If included file creation request, will ensure integrity of the file. # The MD5 checksum of file. If included file creation request, will ensure integrity of the file.
# @return [String] MD5 checksum of file. # @return [String] MD5 checksum of file.
@ -170,6 +172,7 @@ module Fog
options['Content-Type'] = content_type if content_type options['Content-Type'] = content_type if content_type
options['Access-Control-Allow-Origin'] = access_control_allow_origin if access_control_allow_origin options['Access-Control-Allow-Origin'] = access_control_allow_origin if access_control_allow_origin
options['Origin'] = origin if origin options['Origin'] = origin if origin
options['Content-Disposition'] = content_disposition if content_disposition
options.merge!(metadata.to_headers) options.merge!(metadata.to_headers)
data = service.put_object(directory.key, key, body, options) data = service.put_object(directory.key, key, body, options)

View file

@ -2,8 +2,12 @@ Shindo.tests('Fog::Rackspace::Storage | file', ['rackspace']) do
pending if Fog.mocking? pending if Fog.mocking?
def object_attributes(file=@instance)
@instance.service.head_object(@directory.key, file.key).headers
end
def object_meta_attributes(file=@instance) def object_meta_attributes(file=@instance)
@instance.service.head_object(@directory.key, file.key).headers.reject {|k, v| !(k =~ /X-Object-Meta-/)} object_attributes(file).reject {|k, v| !(k =~ /X-Object-Meta-/)}
end end
def clear_metadata def clear_metadata
@ -85,6 +89,11 @@ Shindo.tests('Fog::Rackspace::Storage | file', ['rackspace']) do
@file = @directory.files.create :key => 'meta-test', :body => lorem_file, :metadata => {:works => true } @file = @directory.files.create :key => 'meta-test', :body => lorem_file, :metadata => {:works => true }
object_meta_attributes(@file)["X-Object-Meta-Works"] object_meta_attributes(@file)["X-Object-Meta-Works"]
end end
tests("sets Content-Disposition on create").returns("ho-ho-ho") do
@file = @directory.files.create :key => 'meta-test', :body => lorem_file, :content_disposition => 'ho-ho-ho'
object_attributes(@file)["Content-Disposition"]
end
ensure ensure
@file.destroy if @file @file.destroy if @file
end end