Blob
Blob client class for interacting with Azure Blob Storage.
Table of Contents
-
Methods
- appendBlock(containerbloboptionscontent)
- authorize(methodpathqueryheader)
- createContainer(nameoptions)
- deleteBlob(containerbloboptions)
- deleteContainer(nameoptions)
- getBlob(containerbloboptions)
- getBlobMetadata(containerbloboptions)
- getBlobProperties(containerbloboptions)
- getBlockId(prefixblockNumberlength)
- getBlockList(containerbloboptions)
- getContainerACL(nameoptions)
- getContainerMetadata(nameoptions)
- getContainerProperties(nameoptions)
- getServiceProperties()
- leaseContainer(nameoptions)
- listBlobs(containeroptions)
- listContainers(options)
- putBlob(containerbloboptionscontent)
- putBlock(containerbloboptionscontent)
- putBlockList(containerbloboptions)
- request(methodpathqueryheader)
- sas(containerbloboptions)
- setBlobMetadata(containerblobmetadataoptions)
- setBlobProperties(containerbloboptions)
- setContainerACL(nameoptions)
- setContainerMetadata(namemetadataoptions)
- setServiceProperties(options)
Constructor
Blob
-
options
Parameters:
-
optionsObject- options on the form:
{ // Value for the x-ms-version header fixing the API version version: SERVICE_VERSION, // Value for the x-ms-client-request-id header identifying the client clientId: 'fast-azure-storage', // Server-side request timeout timeout: 30 * 1000, // Delay between client- and server-side timeout clientTimeoutDelay: 500, // Max number of request retries retries: 5, // HTTP Agent to use (defaults to a global azure.Agent instance) agent: azure.Agent.globalAgent, // Multiplier for computation of retry delay: 2 ^ retry * delayFactor delayFactor: 100, // Randomization factor added as: // delay = delay * random([1 - randomizationFactor; 1 + randomizationFactor]) randomizationFactor: 0.25, // Maximum retry delay in ms (defaults to 30 seconds) maxDelay: 30 * 1000, // Error codes for which we should retry transientErrorCodes: TRANSIENT_ERROR_CODES, // Azure storage accountId (required) accountId: undefined, // Azure shared accessKey, required unless options.sas is given accessKey: undefined, // Function that returns SAS string or promise for SAS string, in which // case we will refresh SAS when a request occurs less than // minSASAuthExpiry from signature expiry. This property may also be a // SAS string. sas: undefined, // Minimum SAS expiry before refreshing SAS credentials, if a function for // refreshing SAS credentials is given as options.sas minSASAuthExpiry: 15 * 60 * 1000 }
Methods
appendBlock
-
container -
blob -
options -
content
Commits a new block of data to the end of an existing append blob.
Parameters:
-
containerString- Name of the container
-
blobString- Name of the blob
-
optionsObject- Options on the following form
{ disableContentMD5Check: 'false', // Enable/disable the content md5 check is disabled.(optional) blobConditionMaxSize: '...', // The max length in bytes permitted for the append blob (optional) blobConditionAppendPositionOffset: '...', // A number indicating the byte offset to compare (optional) ifModifiedSince: new Date(), // Specify this to perform the operation only if the resource has // been modified since the specified time. (optional) ifUnmodifiedSince: new Date(), // Specify this to perform the operation only if the resource has // not been modified since the specified date/time. (optional) ifMatch: '...', // ETag value. Specify this to perform the operation only if the // resource's ETag matches the value specified. (optional) ifNoneMatch: '...', // ETag value. Specify this to perform the operation only if the // resource's ETag does not match the value specified. (optional) } -
contentString | Buffer- the content of the block
Returns:
A promise for an object on the form:
{
eTag: '...', // The entity tag for the append blob
lastModified: '...', // The date/time the blob was last modified
contentMD5: '...', // The MD5 hash of the append blob
appendOffset: '...', // The offset at which the block was committed, in bytes.
committedBlockCount: '...', // The number of committed blocks present in the blob.
// This can be used to control how many more appends can be done.
}
createContainer
-
name -
options
Create a new container with the given 'name' under the storage account.
Parameters:
-
nameString- Name of the container to create
-
optionsObject- Options on the following form
{ metadata: '...', // Mapping from metadata keys to values. (optional) publicAccessLevel: '...', // Specifies whether data in the container may be accessed // publicly and the level of access. // Possible values: container, blob. (optional) }
Returns:
a promise for metadata key/value pair A promise for an object on the form:
{
eTag: '...', // The entity tag of the container
lastModified: '...', // The date/time the container was last modified
}
deleteBlob
-
container -
blob -
options
Marks the specified blob for deletion. The blob is later deleted during garbage collection.
Parameters:
-
containerString- Name of the container
-
blobString- Name of the blob
-
optionsObject- Options on the following form
{ ifModifiedSince: new Date(), // Specify this to perform the operation only if the resource has been // modified since the specified time. (optional) ifUnmodifiedSince: new Date(), // Specify this to perform the operation only if the resource has not been // modified since the specified date/time. (optional) ifMatch: '...', // ETag value. Specify this to perform the operation only if the resource's // ETag matches the value specified. (optional) ifNoneMatch: '...', // ETag value. Specify this to perform the operation only if the resource's // ETag does not match the value specified. (optional) }
Returns:
A promise that container has been marked for deletion.
deleteContainer
-
name -
options
Delete container with the given 'name'.
Note, when a container is deleted, a container with the same name cannot be created for at least 30 seconds; the container may not be available for more than 30 seconds if the service is still processing the request. Please see the documentation for more details.
Parameters:
-
nameString- Name of the container to delete
-
optionsObject- Options on the following form
{ leaseId: '...', // Lease unique identifier. A GUID string.(optional) ifModifiedSince: new Date(), // Specify this to perform the operation only if the resource has // been modified since the specified time. (optional) ifUnmodifiedSince: new Date(), // Specify this to perform the operation only if the resource has // not been modified since the specified date/time. (optional) }
Returns:
A promise that container has been marked for deletion.
getBlob
-
container -
blob -
options
Reads or downloads a blob from the system, including its metadata and properties.
Parameters:
-
containerString- Name of the container where the blob should be stored
-
blobString- Name of the blob
-
optionsObject- Options on the following form
{ ifModifiedSince: new Date(), // Specify this to perform the operation only if the resource has been // modified since the specified time. (optional) ifUnmodifiedSince: new Date(), // Specify this to perform the operation only if the resource has not // been modified since the specified date/time. (optional) ifMatch: '...', // ETag value. Specify this to perform the operation only if the resource's // ETag matches the value specified. (optional) ifNoneMatch: '...', // ETag value. Specify this to perform the operation only if the resource's // ETag does not match the value specified. (optional) }
Returns:
A promise for an object on the form:
{
eTag: '...', // The entity tag of the blob
lastModified: '...', // The date/time the blob was last modified.
contentType: '...', // The content type specified for the blob
contentMD5: '...', // The MD5 hash fo the blob
contentEncoding: '...', // The content encoding of the blob
contentLanguage: '...', // The content language of the blob
cacheControl: '...', // The cache control of the blob
contentDisposition: '...', // The content disposition of the blob
pageBlobSequenceNumber: '...', // The current sequence number for a page blob.
type: '...', // The blob type: block, page or append blob.
blobCommittedBlockCount: '...', // The number of committed blocks present in the blob.
// This is returned only for append blobs.
metadata: '...', // Name-value pairs associated with the blob as metadata
content: '...' // The content
}
getBlobMetadata
-
container -
blob -
options
Get the metadata for the blob with the given name.
Note, this is a HEAD request, so if the container is missing you get an
error with err.statusCode = 404, but err.code property will be
ErrorWithoutCode.
Parameters:
-
containerString- the name of the container
-
blobString- the name of the blob
-
optionsObject- Options on the following form
{ ifModifiedSince: new Date(), // Specify this to perform the operation only if the resource has been // modified since the specified time. (optional) ifUnmodifiedSince: new Date(), // Specify this to perform the operation only if the resource has not // been modified since the specified date/time. (optional) ifMatch: '...', // ETag value. Specify this to perform the operation only if the resource's // ETag matches the value specified. (optional) ifNoneMatch: '...', // ETag value. Specify this to perform the operation only if the resource's // ETag does not match the value specified. (optional) }
Returns:
a promise for metadata key/value pair A promise for an object on the form:
{
eTag: '...', // The entity tag of the blob
lastModified: '...', // The date/time the blob was last modified
metadata: '...' // Name-value pairs that correspond to the user-defined metadata
// associated with this blob.
}
getBlobProperties
-
container -
blob -
options
Returns all user-defined metadata, standard HTTP properties, and system properties for the blob.
Parameters:
-
containerString- Name of the container
-
blobString- Name of the blob
-
optionsObject- Options on the following form
{ ifModifiedSince: new Date(), // Specify this to perform the operation only if the resource has been // modified since the specified time. (optional) ifUnmodifiedSince: new Date(), // Specify this to perform the operation only if the resource has not been // modified since the specified date/time. (optional) ifMatch: '...', // ETag value. Specify this to perform the operation only if the resource's // ETag matches the value specified. (optional) ifNoneMatch: '...', // ETag value. Specify this to perform the operation only if the resource's // ETag does not match the value specified. (optional) }
Returns:
A promise for an object on the form:
{
metadata: '...', // Name-value pairs that correspond to the user-defined metadata
// associated with this blob.
lastModified: '...', // The date/time the blob was last modified.
type: '...', // The blob type
leaseDuration: '...', // When a blob is leased, specifies whether the lease is of
// infinite or fixed duration
leaseState: '...', // Lease state of the blob
leaseStatus: '...', // The lease status of the blob.
contentLength: '...', // The size of the blob in bytes
contentType: '...', // The content type specified for the blob
eTag: '...', // The blob Etag
contentMD5: '...' // The content-md5 of the blob
contentEncoding: '...', // The content encoding of the blob
contentLanguage: '...' // The content language of the blob
contentDisposition: '...', // The content disposition of the blob
cacheControl: '...', // The cache control of the blob
pageBlobSequenceNumber: '...', // The current sequence number for a page blob.
committedBlockCount: '...', // The number of committed blocks present in the blob (for append blob).
}
getBlockId
-
prefix -
blockNumber -
length
Generates a base64 string that identifies a block.
Parameters:
-
prefixString- the prefix of the block id
-
blockNumberNumber- the block number
-
lengthNumber- length of the block id
Returns:
- a base64 string as a block identifier
getBlockList
-
container -
blob -
options
Retrieves the list of committed list blocks (that that have been successfully committed to a given blob with putBlockList()), and uncommitted list blocks (that have been uploaded for a blob using Put Block, but that have not yet been committed)
Parameters:
-
containerString- Name of the container
-
blobString- Name of the blob
-
optionsObject- Options on the following form
{ blockListType: 'committed' // Specifies whether to return the list of committed blocks, the list of // uncommitted blocks, or both lists together. Valid values are committed, // uncommitted, or all }
Returns:
A promise for an object on the form:
{
eTag: '...',
committedBlocks: [
{
blockId: '...', // Base64 encoded block identifier
size: '...' // Block size in bytes
}
],
uncommittedBlocks: [
{
blockId: '...', // Base64 encoded block identifier
size: '...' // Block size in bytes
}
]
}
getContainerACL
-
name -
options
Gets the permissions for the container with the given name
Parameters:
-
nameString- Name of the container to get ACL from
-
optionsObject- Options on the following form
{ leaseId: '...' // GUID string; lease unique identifier (optional) }
Returns:
A promise for permissions
{
eTag: '...', // The entity tag of the container
lastModified: '...', // The date/time the container was last modified
publicAccessLevel: '...', // Indicate whether blobs in a container may be accessed publicly.(optional)
// Possible values: container (full public read access for container
// and blob data) or blob (public read access for blobs)
// If it is not specified, the resource will be private and will be
// accessed only by the account owner.
accessPolicies: [{ // The container ACL settings.
// An array with five maximum access policies objects (optional)
id: '...', // Unique identifier, up to 64 chars in length
start: new Date(), // Time from which access policy is valid
expiry: new Date(), // Expiration of access policy
permission: { // Set of permissions delegated
read: false, // Read the content, properties, metadata or block list of a blob or, of
// any blob in the container if the resource is a container.
add: false, // Add a block to an append blob or, to any append blob
// if the resource is a container.
create: false, // Write a new blob, snapshot a blob, or copy a blob to a new blob.
// These operations can be done to any blob in the container
// if the resource is a container.
write: false, // Create or write content, properties, metadata, or block list.
// Snapshot or lease the blob. Resize the blob (page blob only).
// These operations can be done for every blob in the container
// f the resource is a container.
delete: false, // Delete the blob or, any blob in the container if the resource
// is a container.
list: false, // List blobs in the container.
}
}]
}
getContainerMetadata
-
name -
options
Get the metadata for the container with the given name.
Note, this is a HEAD request, so if the container is missing you get an
error with err.statusCode = 404, but err.code property will be
ErrorWithoutCode.
Parameters:
-
nameString- the name of the container to get metadata from.
-
optionsObject- Options on the following form
{ leaseId: '...' // Lease unique identifier. A GUID string.(optional) }
Returns:
a promise for metadata key/value pair A promise for an object on the form:
{
eTag: '...', // The entity tag of the container
lastModified: '...', // The date/time the container was last modified
}
getContainerProperties
-
name -
options
Get all user-defined metadata and system properties for the container with the given name.
Note, this is a HEAD request, so if the container is missing you get an
error with err.statusCode = 404, but err.code property will be
ErrorWithoutCode.
Parameters:
-
nameString- The name of the container to get properties from.
-
optionsObject- Options on the following form
{ leaseId: '...' // GUID string; lease unique identifier (optional) }
Returns:
A promise for an object on the form:
{
metadata: { // Mapping from meta-data keys to values
'<key>': '<value>', // Meta-data key/value pair
...
},
properties: { // System properties
eTag: '...', // The entity tag for the container
lastModified: '...' // The date and time the container was last modified
leaseStatus: '...', // The lease status of the container
leaseState: '...', // Lease state of the container
leaseDuration: '...', // Specifies whether the lease on a container is of infinite or fixed duration.
publicAccessLevel: '...', // Indicates whether data in the container may be accessed publicly and
// the level of access. If this is not returned in the response,
// the container is private to the account owner.
}
}
getServiceProperties
()
Promise
Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules.
Returns:
A promise for an object on the form:
{
logging: { // The Azure Analytics Logging settings.
version: '...', // The version of Storage Analytics to configure
delete: true|false, // Indicates whether all delete requests should be logged
read: true|false, // Indicates whether all read requests should be logged
write: true|false, // Indicates whether all write requests should be logged
retentionPolicy: {
enabled: true|false, // Indicates whether a retention policy is enabled for the storage service
days: '...', // Indicates the number of days that metrics or logging data should be retained.
},
},
hourMetrics: { // The Azure Analytics HourMetrics settings
version: '...', // The version of Storage Analytics to configure
enabled: true|false, // Indicates whether metrics are enabled for the Blob service
includeAPIs: true|false, // Indicates whether metrics should generate summary statistics
// for called API operations.
retentionPolicy: {
enabled: true|false,
days: '...',
},
},
minuteMetrics: { // The Azure Analytics MinuteMetrics settings
version: '...', // The version of Storage Analytics to configure
enabled: true|false, // Indicates whether metrics are enabled for the Blob service
includeAPIs: true|false, // Indicates whether metrics should generate summary statistics
// for called API operations.
retentionPolicy: {
enabled: true|false,
days: '...',
},
},
corsRules: [{ // CORS rules
allowedOrigins: [], // A list of origin domains that will be allowed via CORS,
// or "*" to allow all domains.
allowedMethods: [], // List of HTTP methods that are allowed to be executed by the origin
maxAgeInSeconds: [], // The number of seconds that the client/browser should cache a preflight response
exposedHeaders: [], // List of response headers to expose to CORS clients
allowedHeaders: [], // List of headers allowed to be part of the cross-origin request
}]
}
leaseContainer
-
name -
options
Establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite.
Parameters:
-
nameObject- Name of the container
-
optionsObject- Options on the following form
{ leaseId: '...', // GUID string; it is required in case of renew, change, // or release of the lease leaseAction: '...', // Lease container operation. The possible values are: acquire, renew, // change, release, break (required) leaseBreakPeriod: '...', // For a break operation, proposed duration the lease should continue // before it is broken, in seconds, between 0 and 60. leaseDuration: '...', // Specifies the duration of the lease, in seconds, or negative one (-1) // for a lease that never expires. Required foracquireaction. proposedLeaseId: '...' // GUID string; Optional foracquire, required forchangeaction. ifModifiedSince: new Date(), // Specify this to perform the operation only if the resource has been // modified since the specified time. (optional) ifUnmodifiedSince: new Date(), // Specify this to perform the operation only if the resource has not been // modified since the specified date/time. (optional) }
Returns:
A promise for an object on the form:
{
leaseId: '...', // The unique lease id.
leaseTime: '...' // Approximate time remaining in the lease period, in seconds.
eTag: '...', // The entity tag of the container
lastModified: '...', // The date/time the container was last modified
}
listBlobs
-
container -
options
Get the list of blobs under the specified container.
Parameters:
-
containerString- Name of the container(required)
-
optionsObject- Options on the following form
{ prefix: '...', // Prefix of blobs to list (optional) delimiter: '...', // Delimiter, i.e. '/', for specifying folder hierarchy. (optional) marker: '...', // Marker to list blobs from (optional) maxResults: 5000, // The maximum number of blobs to return (optional) include: { // Specifies one or more datasets to include in the response (optional) snapshots: false, // Include snapshots in listing metadata: false, // Include blob metadata in listing uncommittedBlobs: false, // Include uncommitted blobs in listing copy: false // Include metadata related to any current or previous Copy Blob operation } }
Returns:
A promise for an object on the form:
{
blobs: [
{
name: '...', // Name of blob
snapshot: '...', // A date and time value that uniquely identifies the snapshot
// relative to its base blob
properties: {
lastModified: '...', // The date and time the blob was last modified
eTag: '...', // The entity tag of the blob
contentLength: '...', // The content length of the blob
contentType: '...', // The MIME content type of the blob
contentEncoding: '...', // The content encoding of the blob
contentLanguage: '...', // The content language of the blob
contentMD5: '...', // An MD5 hash of the blob content
cacheControl: '...', // The blob cache control
xmsBlobSequenceNumber: '...', // The page blob sequence number
blobType: '...', // The type of the blob: BlockBlob | PageBlob | AppendBlob
leaseStatus: '...', // The lease status of the blob
leaseState: '...', // The lease state of the blob
leaseDuration: '...', // The lease duration of the blob
copyId: '...', // String identifier for the copy operation
copyStatus: '...', // The state of the copy operation: pending | success | aborted | failed
copySource: '...', // The name of the source blob of the copy operation
copyProgress: '...', // The bytes copied/total bytes
copyCompletionTime: '...', // The date and time the copy operation finished
copyStatusDescription: '...', // The status of the copy operation
serverEncrypted: false, // true if the blob and application metadata are completely encrypted,
// and false otherwise
incrementalCopy: '...', // true for the incremental copy blobs operation and snapshots
}
metadata: {} // Meta-data dictionary if requested
}
],
blobPrefixName: '...',
prefix: '...', // prefix given in options (if given)
marker: '...', // marker given in options (if given)
maxResults: 5000, // maxResults given in options (if given)
nextMarker: '...' // Next marker if not at end of list
delimiter: '...' // Delimiter
}
listContainers
-
options
List the containers under the storage account
Parameters:
-
optionsObject- Options on the following form:
{ prefix: '...', // Prefix of containers to list marker: '...', // Marker to list containers from maxResults: 5000, // Max number of results metadata: false // Whether or not to include metadata }
Returns:
A promise for an object on the form:
{
containers: [
{
name: '...', // Name of container
properties: {
lastModified: '...', // Container's last modified time
eTag: '...', // The entity tag of the container
leaseStatus: '...', // The lease status of the container
leaseState: '...', // The lease state of the container
leaseDuration: '...' // The lease duration of the container
publicAccessLevel: '...' // Indicates whether data in the container may be accessed publicly
// and the level of access. If this is not returned in the response,
// the container is private to the account owner.
}
metadata: {} // Meta-data dictionary if requested
}
],
prefix: '...', // prefix given in options (if given)
marker: '...', // marker given in options (if given)
maxResults: 5000, // maxResults given in options (if given)
nextMarker: '...' // Next marker if not at end of list
}
putBlob
-
container -
blob -
options -
content
Creates a new block, page, or append blob, or updates the content of an existing block blob. Updating an existing block blob overwrites any existing metadata on the blob, and the content of the existing blob is overwritten with the content of the new blob.
Note that a call to a putBlob to create a page blob or an append blob only initializes the blob. To add content to a page blob, call the putPage. To add content to an append blob, call the appendBlock.
Parameters:
-
containerString- Name of the container where the blob should be stored
-
blobString- Name of the blob
-
optionsObject- Options on the following form
{ metadata: '...', // Name-value pairs associated with the blob as metadata contentType: 'application/octet-stream', // The MIME content type of the blob (optional) contentEncoding: '...', // Specifies which content encodings have been applied // to the blob. (optional) contentLanguage: '...', // Specifies the natural languages used by this resource(optional) cacheControl: '...', // The Blob service stores this value but does not // use or modify it. (optional) disableContentMD5Check: 'false', // Enable/disable the content md5 check is disabled.(optional) type: BlockBlob|PageBlob|AppendBlob, // The type of blob to create: block blob, page blob, // or append blob (required) leaseId: '...', // Lease id (required if the blob has an active lease) contentDisposition: '...', // Specifies the content disposition of the blob (optional) ifModifiedSince: new Date(), // Specify this to perform the operation only if the resource // has been modified since the specified time. ifUnmodifiedSince: new Date(), // Specify this to perform the operation only if the resource // has not been modified since the specified date/time. ifMatch: '...', // ETag value. Specify this to perform the operation only if the // resource's ETag matches the value specified. ifNoneMatch: '...', // ETag value. Specify this to perform the operation only if the //resource's ETag does not match the value specified. pageBlobContentLength: '...', // Specifies the maximum size for the page blob, up to 1 TB. // (required for page blobs) pageBlobSequenceNumber: 0, // The sequence number - a user-controlled value that you can use // to track requests (optional, only for page blobs) } -
contentString | Buffer- The content of the blob
Returns:
A promise for an object on the form:
{
eTag: '...', // The entity tag of the blob
lastModified: '...', // The date/time the blob was last modified
contentMD5: '...', // The MD5 hash of the blob
}
putBlock
-
container -
blob -
options -
content
Creates a new block to be committed as part of a blob.
Parameters:
-
containerString- Name of the container
-
blobString- Name of the blob
-
optionsObject- Options on the following form
{ blockId: '...', // A valid Base64 string value that identifies the block // For a given blob, the length of the value specified for the // blockId must be the same size for each block.(required) disableContentMD5Check: 'false', // Enable/disable the content md5 check is disabled.(optional) } -
contentString | Buffer- The content of the block
Returns:
A promise for an object on the form:
{
contentMD5: '...' // The MD5 hash of the block
}
putBlockList
-
container -
blob -
options
Writes a blob by specifying the list of block IDs that make up the blob. In order to be written as part of a blob, a block must have been successfully written to the server in a prior putBlock operation.
Parameters:
-
containerString- Name of the container
-
blobString- Name of the blob
-
optionsObject- Options on the following form
{ cacheControl: '...', // Blob's cache control (optional) contentType: '...', // Blob's content type (optional) contentEncoding: '...', // Blob's content encoding (optional) contentLanguage: '...', // Blob's content language (optional) metadata: '...', // Name-value pairs that correspond to the user-defined metadata // associated with this blob. contentDisposition: '...', // Blob's content disposition ifModifiedSince: new Date(), // Specify this to perform the operation only if the resource has been // modified since the specified time. (optional) ifUnmodifiedSince: new Date(), // Specify this to perform the operation only if the resource has not been // modified since the specified date/time. (optional) ifMatch: '...', // ETag value. Specify this to perform the operation only if the resource's // ETag matches the value specified. (optional) ifNoneMatch: '...', // ETag value. Specify this to perform the operation only if the resource's // ETag does not match the value specified. (optional) committedBlockIds: [], // List of block ids to indicate that the Blob service should search only // the committed block list for the named blocks(optional) uncommittedBlockIds: [], // List of block ids to indicate that the Blob service should search only // the uncommitted block list for the named blocks (optional) latestBlockIds: [], // List of block ids to indicate that the Blob service should first // search the uncommitted block list. If the block is found in the // uncommitted list, that version of the block is the latest and should // be written to the blob. // If the block is not found in the uncommitted list, then the service // should search the committed block list for the named block and write // that block to the blob if it is found. (optional) }
Returns:
- A promise for an object on the form:
{
eTag: '...', // The entity tag of the blob
lastModified: '...', // The date/time the blob was last modified.
}
request
-
method -
path -
query -
header
Make a signed request to path using method in upper-case and all query
parameters and headers keys in lower-case. The request will carry data
as payload and will be retried using the configured retry policy,
Parameters:
-
methodString- HTTP verb in upper case, e.g.
GET.
- HTTP verb in upper case, e.g.
-
pathString- Path on blob resource for storage account.
-
queryObject- Query-string parameters.
-
headerObject- Mapping from header key in lowercase to value.
Returns:
A promise for HTTPS response with payload property as
string containing the response payload.
sas
-
container -
blob -
options
Generate a SAS string on the form 'key1=va1&key2=val2&...'.
Parameters:
-
containerString- Name of the container that this SAS string applies to.
-
blobString- Name of the blob that this SAS string applies to.
-
optionsObject- Options for the following form:
{ start: new Date(), // Time from which signature is valid (optional) expiry: new Date(), // Expiration of signature (required). resourceType: 'blob|container', // Specifies which resources are accessible via the SAS(required) // Possible values are: 'blob' or 'container'. // Specify 'blob' if the shared resource is a 'blob'. // This grants access to the content and metadata of the blob. // Specify 'container' if the shared resource is a 'container'. // This grants access to the content and metadata of any // blob in the container, and to the list of blobs in // the container. permissions: { // Set of permissions delegated (required) // It must be omitted if it has been specified in the associated // stored access policy. read: false, // Read the content, properties, metadata or block list of a blob // or of any blob in the container if the resourceType is // a container. add: false, // Add a block to an append blob or to any append blob if the // resourceType is a container. create: false, // Write a new blob, snapshot a blob, or copy a blob // to a new blob. // These operations can be done to any blob in the container // if the resourceType is a container. write: false, // Create or write content, properties, metadata, or block list. // Snapshot or lease the blob. Resize the blob (page blob only). // These operations can be done for every blob in the container // if the resourceType is a container. delete: false, // Delete the blob or any blob in the container if the // resourceType is a container. list: false, // List blobs in the container. }, cacheControl: '...', // The value of the Cache-Control response header // to be returned. (optional) contentDisposition: '...', // The value of the Content-Disposition response header // to be returned. (optional) contentEncoding: '...', // The value of the Content-Encoding response header // to be returned. (optional) contentLanguage: '...', // The value of the Content-Language response header // to be returned. (optional) contentType: '...', // The value of the Content-Type response header to // be returned. (optional) accessPolicy: '...' // Reference to stored access policy (optional) // A GUID string }
Returns:
Shared-Access-Signature on string form.
setBlobMetadata
-
container -
blob -
metadata -
options
Sets metadata for the specified blob. Overwrites all existing metadata that is associated with that blob.
Parameters:
-
containerString- Name of the container
-
blobString- Name of the blob
-
metadataObject- Mapping from metadata keys to values.
-
optionsObject- Options on the following form
{ ifModifiedSince: new Date(), // Specify this to perform the operation only if the resource has been // modified since the specified time. (optional) ifUnmodifiedSince: new Date(), // Specify this to perform the operation only if the resource has not // been modified since the specified date/time. (optional) ifMatch: '...', // ETag value. Specify this to perform the operation only if the resource's // ETag matches the value specified. (optional) ifNoneMatch: '...', // ETag value. Specify this to perform the operation only if the resource's // ETag does not match the value specified. (optional) }
Returns:
A promise for an object on the form:
{
eTag: '...', // The entity tag of the blob
lastModified: '...' // The date/time the blob was last modified.
}
setBlobProperties
-
container -
blob -
options
Sets system properties on the blob
Parameters:
-
containerString- Name of the container
-
blobString- Name of the blob
-
optionsObject- Options on the following form
{ cacheControl: '...', // The cache control string for the blob (optional) // If this property is not specified, then the property // will be cleared for the blob. contentType: '...', // The MIME content type of the blob (optional) // If this property is not specified, then the property // will be cleared for the blob. contentMD5: '...', // The MD5 hash of the blob (optional) // If this property is not specified, then the property // will be cleared for the blob. contentEncoding: '...', // The content encodings of the blob. (optional) // If this property is not specified, then the property // will be cleared for the blob. contentLanguage: '...', // The content language of the blob. (optional) // If this property is not specified, then the property // will be cleared for the blob. contentDisposition: '...', // The content disposition (optional) // If this property is not specified, then the property // will be cleared for the blob. pageBlobContentLength: '...', // The new size of a page blob. If the specified value is // less than the current size of the blob, then all pages // above the specified value are cleared. // This property applies to page blobs only. pageBlobSequenceNumberAction: 'max|update|increment', // Indicates how the service should modify the blob's // sequence number. // - max: Sets the sequence number to be the higher of the // value included with the request and the value // currently stored for the blob. // - update: Sets the sequence number to the value // included with the request. // - increment: Increments the value of the sequence // number by 1. // This property applies to page blobs only. (optional) pageBlobSequenceNumber: '...', // The page blob sequence number. // Optional, but required if the //pageBlobSequenceNumberActionoption is set tomax// orupdate. // This property applies to page blobs only. ifModifiedSince: new Date(), // Specify this to perform the operation only if the // resource has been modified since the specified time. // (optional) ifUnmodifiedSince: new Date(), // Specify this to perform the operation only if the // resource has not been modified since the specified // date/time. (optional) ifMatch: '...', // ETag value. Specify this to perform the operation only // if the resource's ETag matches the value specified. // (optional) ifNoneMatch: '...', // ETag value. Specify this to perform the operation only // if the resource's ETag does not match the value // specified. (optional) }
Returns:
A promise for an object on the form:
{
eTag: '...', // The entity tag of the blob
lastModified: '...', // The date/time the blob was last modified
blobSequenceNumber: '...', // The blob's current sequence number (if the blob is a page blob)
}
setContainerACL
-
name -
options
Sets the permissions for the container with the given name. The permissions indicate whether blobs in a container may be accessed publicly.
Parameters:
-
nameString- Name of the container to set ACL to
-
optionsObject- Options on the following form
{ publicAccessLevel: '...', // Indicate whether blobs in a container may be accessed publicly.(optional) // Possible values: container (full public read access for container // and blob data) or blob (public read access for blobs). // If it is not specified, the resource will be private and will be accessed // only by the account owner. accessPolicies: [{ // The container ACL settings. // An array with five maximum access policies objects (optional) id: '...', // Unique identifier, up to 64 chars in length start: new Date(), // Time from which access policy is valid expiry: new Date(), // Expiration of access policy permission: { // Set of permissions delegated read: false, // Read the content, properties, metadata or block list of a blob or of // any blob in the container if the resourceType is a container. add: false, // Add a block to an append blob or to any append blob // if the resourceType is a container. create: false, // Write a new blob, snapshot a blob, or copy a blob to a new blob. // These operations can be done to any blob in the container // if the resourceType is a container. write: false, // Create or write content, properties, metadata, or block list. // Snapshot or lease the blob. Resize the blob (page blob only). // These operations can be done for every blob in the container // if the resourceType is a container. delete: false, // Delete the blob or any blob in the container // if the resourceType is a container. list: false, // List blobs in the container. } }], leaseId: '...', // GUID string; lease unique identifier (optional) ifModifiedSince: new Date(), // Specify this to perform the operation only if the resource has // been modified since the specified time. (optional) ifUnmodifiedSince: new Date(), // Specify this to perform the operation only if the resource has // not been modified since the specified date/time. (optional) }
Returns:
a promise for metadata key/value pair A promise for an object on the form:
{
eTag: '...', // The entity tag of the container
lastModified: '...', // The date/time the container was last modified
}
setContainerMetadata
-
name -
metadata -
options
Sets metadata for the specified container. Overwrites all existing metadata that is associated with the container.
Parameters:
-
nameString- Name of the container to set metadata on
-
metadataObject- Mapping from metadata keys to values.
-
optionsObject- Options on the following form
{ leaseId: '...', // Lease unique identifier. A GUID string.(optional) ifModifiedSince: new Date(), // Specify this to perform the operation only if the resource has been // modified since the specified time. (optional) }
Returns:
a promise for metadata key/value pair A promise for an object on the form:
{
eTag: '...', // The entity tag of the container
lastModified: '...', // The date/time the container was last modified
}
setServiceProperties
-
options
Sets properties for a storage account’s Blob service endpoint
Parameters:
-
optionsObject- Options on the following form:
{ logging: { // The Azure Analytics Logging settings. version: '...', // The version of Storage Analytics to configure (required if logging specified) delete: true|false, // Indicates whether all delete requests should be logged // (required if logging specified) read: true|false, // Indicates whether all read requests should be logged // (required if logging specified) write: true|false, // Indicates whether all write requests should be logged // (required if logging specified) retentionPolicy: { enabled: true|false, // Indicates whether a retention policy is enabled for the // storage service. (required) days: '...', // Indicates the number of days that metrics or logging data should be retained. // Required only if a retention policy is enabled. }, }, hourMetrics: { // The Azure Analytics HourMetrics settings version: '...', // The version of Storage Analytics to configure // (required if hourMetrics specified) enabled: true|false, // Indicates whether metrics are enabled for the Blob service //(required if hourMetrics specified). includeAPIs: true|false, // Indicates whether metrics should generate summary statistics for called API // operations (Required only if metrics are enabled). retentionPolicy: { enabled: true|false, days: '...', }, }, minuteMetrics: { // The Azure Analytics MinuteMetrics settings version: '...', // The version of Storage Analytics to configure // (required if minuteMetrics specified) enabled: true|false, // Indicates whether metrics are enabled for the Blob service // (required if minuteMetrics specified). includeAPIs: true|false, // Indicates whether metrics should generate summary statistics for called API // operations (Required only if metrics are enabled). retentionPolicy: { enabled: true|false, days: '...', }, }, corsRules: [{ // CORS rules allowedOrigins: [], // A list of origin domains that will be allowed via CORS, // or "*" to allow all domains allowedMethods: [], // List of HTTP methods that are allowed to be executed by the origin maxAgeInSeconds: [], // The number of seconds that the client/browser should cache a // preflight response exposedHeaders: [], // List of response headers to expose to CORS clients allowedHeaders: [], // List of headers allowed to be part of the cross-origin request }] }
Returns:
A promise that the properties have been set