HPCloud-JS

API Docs for: 1.0.0
Show:

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:

  • name String

    The name of the object.

  • [contentType] String optional

    (Optional) The type of content, defaults to Application/X-Octet-Stream.

Methods

additionalHeaders

() Object

EXPERT: Get any additional headers.

Returns:

Object: Additional headers

addMetadatum

(
  • name
  • value
)

Add a name/value pair to the metadata.

If this entry exists already, it will be overwritten.

Parameters:

  • name String

    The name.

  • value String

    The value.

contentLength

() Number

Get the content length of the object

Returns:

Number: The length of the content in bytes.

contentType

() String

Get the content type of the current object.

Returns:

String: The type of content in the object.

decodeMetadata

(
  • headers
)
Object static

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:

  • headers Object

    The raw headers.

Returns:

Object: The metadata name/value pairs.

deleteMetadatum

(
  • name
)

Remove a key/value pair from the metadata.

This will remove a named item if it exists.

Parameters:

  • name String

    The metadatum name.

disposition

() String

Get the object's disposition.

Throws Error When the results are partial, and error is thrown.

Returns:

String: The content disposition.

eTag

() String

Get the etag of the object

Returns:

String: The etag of the object. This is a md5 hash.

hasMetadatum

(
  • name
)

Check whether a value exists.

NULL is treated as false.

Parameters:

  • name String

    The name to search for.

lastModified

() String

The last modified date

Returns:

String: The last modified date.

mergeAdditionalHeaders

(
  • headers
)

Merge additional headers into a supplied headers object.

Headers are modified in place.

Parameters:

  • headers Object

    The existing headers.

mergeMetadataHeaders

(
  • headers
)

Merge metadata into a supplied headers object.

Headers are modified in place.

Parameters:

  • headers Object

    The 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:

Object: An object containting names/values of metadata.

name

() String

Get the objects name.

Returns:

String: The name of the object.

newFromJSON

(
  • An
)
ObjectInfo static

Create a new ObjectInfo instance from JSON data.

Parameters:

  • An Object

    object from a JSON response.

Returns:

ObjectInfo: A new ObjectInfo object.

newFromResponse

(
  • name
  • response
)
ObjectInfo static

Create a new ObjectInfo from an HTTP Client Response.

Parameters:

  • name String

    The name of an object

  • response Object

    A HTTP response for an object.

Returns:

ObjectInfo: A new ObjectInfo object.

removeHeaders

(
  • list
)

EXPERT: Remove headers from the additional header field.

Parameters:

  • list Array

    A list of header keys to remove from the object headers.

setAdditionalHeaders

(
  • headers
)
ObjectInfo chainable

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:

  • headers Object

    This is a headers object.

Returns:

ObjectInfo: this

setContentLength

(
  • bytes
)
ObjectInfo chainable

Set the content length for the object.

Parameters:

  • bytes Number

    Number of bytes of the object content.

Returns:

ObjectInfo: this

setContentType

(
  • contentType
)
ObjectInfo chainable

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:

  • contentType String

    The content type.

Returns:

ObjectInfo: this

setDisposition

(
  • disposition
)
ObjectInfo chainable

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:

  • disposition String

    The content disposition.

Returns:

ObjectInfo: this

setETag

(
  • md5
)
ObjectInfo chainable

Set the ETag value

Parameters:

  • md5 String

    md5 hash for the etag.

Returns:

ObjectInfo: this

setLastModified

(
  • lastmod
)
ObjectInfo chainable

Set the last modified date

Parameters:

  • lastmod String

    The date and time the object was last modified.

Returns:

ObjectInfo: this

setMetadata

(
  • metadata
)
ObjectInfo chainable

Set the metadata for this object.

Parameters:

  • metadata Object

    Name/value pairs to be added as metadata.

Returns:

ObjectInfo: this

setName

(
  • name
)
ObjectInfo chainable

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:

  • name String

    The new name.

Returns:

ObjectInfo: this

setTransferEncoding

(
  • encoding
)
ObjectInfo chainable

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:

  • encoding String

    The encoding.

Returns:

ObjectInfo: this

transferEncoding

() String

Get the object's trasport encoding.

Throws Error When the results are partial, and error is thrown.

Returns:

String: The transfer encoding.

Properties

DEFAULT_CONTENT_TYPE

String

The default content type.