Method: CloudFiles::StorageObject#set_metadata
- Defined in:
- lib/cloudfiles/storage_object.rb
#set_metadata(metadatahash) ⇒ Object Also known as: metadata=
Sets the metadata for an object. By passing a hash as an argument, you can set the metadata for an object. However, setting metadata will overwrite any existing metadata for the object.
Throws NoSuchObjectException if the object doesn’t exist. Throws InvalidResponseException if the request fails.
145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/cloudfiles/storage_object.rb', line 145 def () headers = {} .each{ |key, value| headers['X-Object-Meta-' + key.to_s.capitalize] = value.to_s } begin SwiftClient.post_object(self.container.connection.storageurl, self.container.connection.authtoken, self.container.escaped_name, (CloudFiles.escape self.name), headers) true rescue ClientException => e raise CloudFiles::Exception::NoSuchObject, "Object #{@name} does not exist" if (e.status.to_s == "404") raise CloudFiles::Exception::InvalidResponse, "Invalid response code #{e.status.to_s}" unless (e.status.to_s =~ /^20/) false end end |