Retrieving an object

You use the HTTP GET method to retrieve an object from a container. Retrieving an object means retrieving the object data. To retrieve an object, you need read permission for the container containing the object or for the object itself.

A request to retrieve an object retrieves the current version of the object. This happens regardless of whether or not versioning is enabled.

If a retrieved object has custom metadata, the headers returned in response to the request include the X-Object-Meta-name header which lists the name of each metadata item.

Retrieving part of an object

You can use the Range header in a GET request to retrieve only part of an object. By using the Range header, you can limit the amount of data returned, even when you don't know the size of the object.

The value of the Range header is the range of bytes you want to retrieve. The first byte of the data for an object is in position 0 (zero), so a range of 1-5 specifies the second through sixth bytes, not the first through fifth.

To specify a byte range in a range header, you use this format:

"Range: bytes=byte-range"

The table below shows the valid values for byte-range.

 

Value Description Example
start-position – end-position

Bytes in start-position through end-position, inclusive. If the end-position is greater than the size of the object data, HCP returns the bytes in start-position through the end of the data.

Valid values for start-position and end-position are integers greater than or equal to zero.

For the specified range to be valid, end-position must be greater than or equal to start-position.

Five hundred bytes beginning with the two-hundred-first:

bytes=200-699

start-position –

Bytes in start-position through the end of the object data.

Valid values for start-position are integers greater than or equal to zero.

All the bytes beginning with the seventy-sixth and continuing through the end of the object data:

bytes=75-

– offset-from-end

Bytes in the offset-from-end position, counted back from the last position in the object data, through the end of the object data. If offset-from-end is greater than the size of the object data, HCP returns the complete object data.

Valid values for offset-from-end are integers greater than or equal to zero.

The last 25 bytes of the object data:

bytes=-25

These considerations apply to Range header values:

If you specify a valid range in which the start position is less than the size of the object data, HCP returns the requested range of data with a 200 (Success) status code.

If you specify a valid range in which the start position is greater than or equal to the size of the object data, HCP returns a 412 (Precondition Failed) status code and does not return any data.

If you specify an offset of zero, HCP returns a 412 (Precondition Failed) status code and does not return any data.

If you specify an invalid value (for example, a value in which the start position is greater than the end position, HCP ignores the Range header and returns the complete object data with a status code of 200 (OK).

Conditionally retrieving an object

You can choose to retrieve an object only if its ETag and/or last modification date and time meet certain criteria.  You might do this, for example, in an application that maintains a local cache of frequently used objects. With such an application, you can reduce the load on HCP and the network by retrieving objects only if they have changed in some way since they were cached.

You use the If-Match, If-None-Match, If-Modified-Since, and If-Unmodified-Since request headers to make GET request conditional:

The If-Match and If-None-Match headers compare the ETag for the requested object to one or more values that you specify. Typically, each value is the ETag for an object of interest.

The If-Modified-Since and If-Unmodified-Since headers compare the date and time the requested object was last modified to a date and time that you specify.

If the requested object meets all the conditions specified by the conditional headers included in the request, HCP returns the object data. If the specified item does not meet the condition specified by:

An If-Match or If-Unmodified-Since header, HCP returns a 412 (Precondition Failed) status code and does not return the object data

An If-None-Match or If-Modified-Since header, HCP returns a 304 (Not Modified) status code and does not return the object data

If a request includes multiple different conditional headers, HCP processes any If-Match and If-None-Match headers before any If-Modified-Since or If-Unmodified-Since headers. If a request includes more than one of any given header, HCP processes only the first one of those headers and ignores the others.

Trademarks and Legal Disclaimer

© 2017 Hitachi Data Systems Corporation. All rights reserved.