mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge pull request #3755 from ben-ole/feature-enhance-openstack
openstack swift file: added content-encoding support
This commit is contained in:
commit
8d37c603b3
2 changed files with 38 additions and 0 deletions
|
@ -26,6 +26,13 @@ module Fog
|
|||
# @see http://docs.openstack.org/developer/swift/overview_expiring_objects.html
|
||||
attribute :delete_after, :aliases => ['X-Delete-After']
|
||||
|
||||
# @!attribute [rw] content_encoding
|
||||
# When you create an object or update its metadata, you can optionally set the Content-Encoding metadata.
|
||||
# This metadata enables you to indicate that the object content is compressed without losing the identity of the
|
||||
# underlying media type (Content-Type) of the file, such as a video.
|
||||
# @see http://docs.openstack.org/developer/swift/api/use_content-encoding_metadata.html#use-content-encoding-metadata
|
||||
attribute :content_encoding, :aliases => 'Content-Encoding'
|
||||
|
||||
def body
|
||||
attributes[:body] ||= if last_modified
|
||||
collection.get(identity).body
|
||||
|
@ -47,6 +54,7 @@ module Fog
|
|||
options['Content-Type'] ||= content_type if content_type
|
||||
options['Access-Control-Allow-Origin'] ||= access_control_allow_origin if access_control_allow_origin
|
||||
options['Origin'] ||= origin if origin
|
||||
options['Content-Encoding'] ||= content_encoding if content_encoding
|
||||
service.copy_object(directory.key, key, target_directory_key, target_file_key, options)
|
||||
target_directory = service.directories.new(:key => target_directory_key)
|
||||
target_directory.files.get(target_file_key)
|
||||
|
@ -101,6 +109,7 @@ module Fog
|
|||
options['Origin'] = origin if origin
|
||||
options['X-Delete-At'] = delete_at if delete_at
|
||||
options['X-Delete-After'] = delete_after if delete_after
|
||||
options['Content-Encoding'] = content_encoding if content_encoding
|
||||
options.merge!(metadata_to_headers)
|
||||
|
||||
data = service.put_object(directory.key, key, body, options)
|
||||
|
|
|
@ -215,6 +215,35 @@ Shindo.tests('Fog::OpenStack::Storage | file', ['openstack']) do
|
|||
|
||||
end
|
||||
|
||||
tests("#content_encoding") do
|
||||
|
||||
tests("#content_encoding should default to nil").returns(nil) do
|
||||
@instance.save
|
||||
@instance.content_encoding
|
||||
end
|
||||
|
||||
@instance.content_encoding = 'gzip'
|
||||
@instance.save
|
||||
tests("#content_encoding should return the content encoding").returns('gzip') do
|
||||
@instance.content_encoding
|
||||
end
|
||||
@instance.attributes.delete('content_encoding')
|
||||
|
||||
@instance.content_encoding = 'foo'
|
||||
@instance.save
|
||||
tests("#content_encoding= should update content_encoding").returns('bar') do
|
||||
@instance.content_encoding = 'bar'
|
||||
@instance.save
|
||||
@instance.content_encoding
|
||||
end
|
||||
|
||||
tests("#content_encoding= should not blow up on nil") do
|
||||
@instance.content_encoding = nil
|
||||
@instance.save
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@directory.destroy
|
||||
|
|
Loading…
Add table
Reference in a new issue