ObjectInfo Class
Build a new ObjectInfo instance.
This represents the data about an object. It is used under the following circumstances:
- SAVING: When creating a new object, you declare the object as ObjectInfo. When saving, you will save with an ObjectInfo and a Stream of data. See Container.save().
- LISTING: When calling Container.objects(), a list including ObjectInfo items will be returned.
- FETCHING METADATA: Using Container.objectInfo(), you can get just the info about an object, without downloading the entire object.
- FETCHING OBJECT: When you fetch the entire object, you will also get the ObjectInfo. See RemoteObject.info().
- UPATING METADATA: When updating just the metadata on an object, you will supply an ObjectInfo object.
Constructor
ObjectInfo
-
name -
[contentType]
Parameters:
-
nameStringThe name of the object.
-
[contentType]String optional(Optional) The type of content, defaults to Application/X-Octet-Stream.
Item Index
Methods
- additionalHeaders
- addMetadatum
- contentLength
- contentType
- decodeMetadata static
- deleteMetadatum
- disposition
- eTag
- hasMetadatum
- lastModified
- mergeAdditionalHeaders
- mergeMetadataHeaders
- metadata
- name
- newFromJSON static
- newFromResponse static
- removeHeaders
- setAdditionalHeaders
- setContentLength
- setContentType
- setDisposition
- setETag
- setLastModified
- setMetadata
- setName
- setTransferEncoding
- transferEncoding
Properties
Methods
additionalHeaders
()
Object
EXPERT: Get any additional headers.
Returns:
addMetadatum
-
name -
value
Add a name/value pair to the metadata.
If this entry exists already, it will be overwritten.
Parameters:
-
nameStringThe name.
-
valueStringThe value.
contentLength
()
Number
Get the content length of the object
Returns:
contentType
()
String
Get the content type of the current object.
Returns:
decodeMetadata
-
headers
Fetch the metadata from the headers and return them.
This does not decode the value, since we do not know anyting about the value's encoding.
Parameters:
-
headersObjectThe raw headers.
Returns:
deleteMetadatum
-
name
Remove a key/value pair from the metadata.
This will remove a named item if it exists.
Parameters:
-
nameStringThe metadatum name.
disposition
()
String
Get the object's disposition.
Throws Error When the results are partial, and error is thrown.
Returns:
eTag
()
String
Get the etag of the object
Returns:
hasMetadatum
-
name
Check whether a value exists.
NULL is treated as false.
Parameters:
-
nameStringThe name to search for.
lastModified
()
String
The last modified date
Returns:
mergeAdditionalHeaders
-
headers
Merge additional headers into a supplied headers object.
Headers are modified in place.
Parameters:
-
headersObjectThe existing headers.
mergeMetadataHeaders
-
headers
Merge metadata into a supplied headers object.
Headers are modified in place.
Parameters:
-
headersObjectThe existing headers.
metadata
()
Object
Get metadata.
This will only be available if ObjectInfo.is
Throws Error When the results are partial, and error is thrown.
Returns:
name
()
String
Get the objects name.
Returns:
newFromJSON
-
An
Create a new ObjectInfo instance from JSON data.
Parameters:
-
AnObjectobject from a JSON response.
Returns:
newFromResponse
-
name -
response
Create a new ObjectInfo from an HTTP Client Response.
Parameters:
-
nameStringThe name of an object
-
responseObjectA HTTP response for an object.
Returns:
removeHeaders
-
list
EXPERT: Remove headers from the additional header field.
Parameters:
-
listArrayA list of header keys to remove from the object headers.
setAdditionalHeaders
-
headers
EXPERT: Set additional headers.
Set additional HTTP headers for Swift. Note, this is not to add to the additional headers but to set them replacing any that already exist.
Parameters:
-
headersObjectThis is a headers object.
Returns:
setContentLength
-
bytes
Set the content length for the object.
Parameters:
-
bytesNumberNumber of bytes of the object content.
Returns:
setContentType
-
contentType
Set the content type (MIME type) of the object.
The default type is application/x=octet-stream'. You may
also add encoding information, such astext/html; charset=iso-8859-13`.
In fact, any options HTTP allows, you can add.
Content type is neither parsed nor verified before being sent to the remote object storage.
Parameters:
-
contentTypeStringThe content type.
Returns:
setDisposition
-
disposition
Set the content disposition.
Commonly, this is used to force a user agent to prompt for download instead of attempting to display.
Example: o->setDisposition('attachment; filename=foo.png')
When a disposition is submitted, it will be returned in the object headers upon GET request.
Parameters:
-
dispositionStringThe content disposition.
Returns:
setETag
-
md5
Set the ETag value
Parameters:
-
md5Stringmd5 hash for the etag.
Returns:
setLastModified
-
lastmod
Set the last modified date
Parameters:
-
lastmodStringThe date and time the object was last modified.
Returns:
setMetadata
-
metadata
Set the metadata for this object.
Parameters:
-
metadataObjectName/value pairs to be added as metadata.
Returns:
setName
-
name
Set the new name of this object.
Note that this only changes the local copy of the object. An object must be saved before the server copy is changed.
Parameters:
-
nameStringThe new name.
Returns:
setTransferEncoding
-
encoding
Set the transfer encoding.
NOTE: This is informational, and will not cause any processing. If you mark an object as gzipped, it is up to you to do the gzipping.
This allows you to save, say, a compressed copy of a file and tell Object Storage that the file is of type foo/bar, but is encoded with gzip.
Common encoding types: - gzip - zip - compress
Since object storage does not attempt to decode objects, you can use any value your system supports.
Parameters:
-
encodingStringThe encoding.
Returns:
transferEncoding
()
String
Get the object's trasport encoding.
Throws Error When the results are partial, and error is thrown.
Returns:
Properties
DEFAULT_CONTENT_TYPE
String
The default content type.
HPCloud-JS