@azure/storage-file package
Classes
Aborter |
An aborter instance implements AbortSignal interface, can abort HTTP requests.
For an existing instance aborter:
|
AccountSASPermissions |
ONLY AVAILABLE IN NODE.JS RUNTIME. This is a helper class to construct a string representing the permissions granted by an AccountSAS. Setting a value to true means that any SAS which uses these permissions will grant permissions for that operation. Once all the values are set, this should be serialized with toString and set as the permissions field on an <xref:IAccountSASSignatureValues> object. It is possible to construct the permissions string without this class, but the order of the permissions is particular and this class guarantees correctness. |
AccountSASResourceTypes |
ONLY AVAILABLE IN NODE.JS RUNTIME. This is a helper class to construct a string representing the resources accessible by an AccountSAS. Setting a value to true means that any SAS which uses these permissions will grant access to that resource type. Once all the values are set, this should be serialized with toString and set as the resources field on an <xref:IAccountSASSignatureValues> object. It is possible to construct the resources string without this class, but the order of the resources is particular and this class guarantees correctness. |
AccountSASServices |
ONLY AVAILABLE IN NODE.JS RUNTIME. This is a helper class to construct a string representing the services accessible by an AccountSAS. Setting a value to true means that any SAS which uses these permissions will grant access to that service. Once all the values are set, this should be serialized with toString and set as the services field on an <xref:IAccountSASSignatureValues> object. It is possible to construct the services string without this class, but the order of the services is particular and this class guarantees correctness. |
BrowserPolicyFactory |
BrowserPolicyFactory is a factory class helping generating BrowserPolicy objects. |
DirectoryURL |
A DirectoryURL represents a URL to the Azure Storage directory allowing you to manipulate its files and directories. |
FileSASPermissions |
ONLY AVAILABLE IN NODE.JS RUNTIME. This is a helper class to construct a string representing the permissions granted by a ServiceSAS to a file. Setting a value to true means that any SAS which uses these permissions will grant permissions for that operation. Once all the values are set, this should be serialized with toString and set as the permissions field on a <xref:IFileSASSignatureValues> object. It is possible to construct the permissions string without this class, but the order of the permissions is particular and this class guarantees correctness. |
FileSystemAttributes |
This is a helper class to construct a string representing the NTFS attributes to a file or directory. |
FileURL |
A FileURL represents a URL to an Azure Storage file. |
KeepAlivePolicyFactory |
KeepAlivePolicyFactory is a factory class helping generating KeepAlivePolicy objects. |
LoggingPolicyFactory |
LoggingPolicyFactory is a factory class helping generating LoggingPolicy objects. |
Pipeline |
A Pipeline class containing HTTP request policies. You can create a default Pipeline by calling StorageURL.newPipeline(). Or you can create a Pipeline with your own policies by the constructor of Pipeline. Refer to StorageURL.newPipeline() and provided policies as reference before implementing your customized Pipeline. |
RetryPolicyFactory |
RetryPolicyFactory is a factory class helping generating RetryPolicy objects. |
SASQueryParameters |
Represents the components that make up an Azure Storage SAS' query parameters. This type is not constructed directly by the user; it is only generated by the <xref:IAccountSASSignatureValues> and <xref:IFileSASSignatureValues> types. Once generated, it can be encoded into a {@code String} and appended to a URL directly (though caution should be taken here in case there are existing query parameters, which might affect the appropriate means of appending these query parameters). NOTE: Instances of this class are immutable. |
ServiceURL |
A ServiceURL represents a URL to the Azure Storage File service allowing you to manipulate file shares. |
ShareSASPermissions |
This is a helper class to construct a string representing the permissions granted by a ServiceSAS to a share. Setting a value to true means that any SAS which uses these permissions will grant permissions for that operation. Once all the values are set, this should be serialized with toString and set as the permissions field on a <xref:IFileSASSignatureValues> object. It is possible to construct the permissions string without this class, but the order of the permissions is particular and this class guarantees correctness. |
ShareURL |
A ShareURL represents a URL to the Azure Storage share allowing you to manipulate its directories and files. |
StorageURL |
A ServiceURL represents a based URL class for ServiceURL, ContainerURL and etc. |
TelemetryPolicyFactory |
TelemetryPolicyFactory is a factory class helping generating TelemetryPolicy objects. |
UniqueRequestIDPolicyFactory |
UniqueRequestIDPolicyFactory is a factory class helping generating UniqueRequestIDPolicy objects. |
AnonymousCredential |
AnonymousCredential provides a credentialPolicyCreator member used to create AnonymousCredentialPolicy objects. AnonymousCredentialPolicy is used with HTTP(S) requests that read public resources or for use with Shared Access Signatures (SAS). |
Credential |
Credential is an abstract class for Azure Storage HTTP requests signing. This class will host an credentialPolicyCreator factory which generates CredentialPolicy. |
SharedKeyCredential |
ONLY AVAILABLE IN NODE.JS RUNTIME. SharedKeyCredential for account key authorization of Azure Storage service. |
Directory |
Class representing a Directory. |
File |
Class representing a File. |
Service |
Class representing a Service. |
Share |
Class representing a Share. |
StorageClient | |
StorageClientContext | |
AnonymousCredentialPolicy |
AnonymousCredentialPolicy is used with HTTP(S) requests that read public resources or for use with Shared Access Signatures (SAS). |
BrowserPolicy |
BrowserPolicy will handle differences between Node.js and browser runtime, including:
|
CredentialPolicy |
Credential policy used to sign HTTP(S) requests before sending. This is an abstract class. |
KeepAlivePolicy |
KeepAlivePolicy is a policy used to control keep alive settings for every request. |
LoggingPolicy |
LoggingPolicy is a policy used to log requests. |
RetryPolicy |
Retry policy with exponential retry and linear retry implemented. |
SharedKeyCredentialPolicy |
SharedKeyCredentialPolicy is a policy used to sign HTTP request with a shared key. |
TelemetryPolicy |
TelemetryPolicy is a policy used to tag user-agent header for every requests. |
UniqueRequestIDPolicy |
UniqueRequestIDPolicy generates an UUID as x-ms-request-id header value. |
Batch |
Batch provides basic parallel execution with concurrency limits. Will stop execute left operations when one of the executed operation throws an error. But Batch cannot cancel ongoing operations, you need to cancel them by yourself. |
BufferScheduler |
This class accepts a Node.js Readable stream as input, and keeps reading data from the stream into the internal buffer structure, until it reaches maxBuffers. Every available buffer will try to trigger outgoingHandler. The internal buffer structure includes an incoming buffer array, and a outgoing buffer array. The incoming buffer array includes the "empty" buffers can be filled with new incoming data. The outgoing array includes the filled buffers to be handled by outgoingHandler. Every above buffer size is defined by parameter bufferSize. NUM_OF_ALL_BUFFERS = BUFFERS_IN_INCOMING + BUFFERS_IN_OUTGOING + BUFFERS_UNDER_HANDLING NUM_OF_ALL_BUFFERS <= maxBuffers PERFORMANCE IMPROVEMENT TIPS:
|
RetriableReadableStream |
ONLY AVAILABLE IN NODE.JS RUNTIME. A Node.js ReadableStream will internally retry when internal ReadableStream unexpected ends. |
Interfaces
IDirectoryCreateOptions | |
IDirectoryForceCloseHandlesSegmentOptions | |
IDirectoryListFilesAndDirectoriesSegmentOptions | |
IDirectoryListHandlesSegmentOptions | |
IDirectoryProperties | |
IFileCreateOptions | |
IFileDownloadOptions | |
IFileGetRangeListOptions |
The option is defined as parity to REST definition. While it's not ready to be used now, considering Crc64 of source content is not accessible. |
IFileListHandlesSegmentOptions | |
IFileProperties | |
IFileStartCopyOptions | |
IFileUploadRangeOptions | |
ISetPropertiesResponse | |
IAccountSASSignatureValues |
ONLY AVAILABLE IN NODE.JS RUNTIME. IAccountSASSignatureValues is used to generate a Shared Access Signature (SAS) for an Azure Storage account. Once all the values here are set appropriately, call generateSASQueryParameters() to obtain a representation of the SAS which can actually be applied to file urls. Note: that both this class and <xref:SASQueryParameters> exist because the former is mutable and a logical representation while the latter is immutable and used to generate actual REST requests. |
IFileSASSignatureValues |
ONLY AVAILABLE IN NODE.JS RUNTIME. IFileSASSignatureValues is used to help generating File service SAS tokens for shares or files. |
IIPRange |
Allowed IP range for a SAS. |
IRange |
Range for Service Operations. |
IKeepAliveOptions |
Interface of KeepAlivePolicy options. |
IRequestLogOptions |
RequestLogOptions configures the retry policy's behavior. |
IPipelineOptions |
Option interface for Pipeline constructor. |
IRetryOptions |
Retry options interface. |
IServiceListSharesSegmentOptions | |
IShareCreateOptions | |
IShareCreateSnapshotOptions | |
IShareDeleteMethodOptions | |
ISignedIdentifier | |
INewPipelineOptions |
Option interface for Pipeline.newPipeline method. |
ITelemetryOptions |
Interface of TelemetryPolicy options. |
AccessPolicy |
An Access policy. |
CorsRule |
CORS is an HTTP feature that enables a web application running under one domain to access resources in another domain. Web browsers implement a security restriction known as same-origin policy that prevents a web page from calling APIs in a different domain; CORS provides a secure way to allow one domain (the origin domain) to call APIs in another domain. |
DirectoryCreateHeaders |
Defines headers for Create operation. |
DirectoryCreateOptionalParams |
Optional Parameters. |
DirectoryDeleteHeaders |
Defines headers for Delete operation. |
DirectoryDeleteMethodOptionalParams |
Optional Parameters. |
DirectoryForceCloseHandlesHeaders |
Defines headers for ForceCloseHandles operation. |
DirectoryForceCloseHandlesOptionalParams |
Optional Parameters. |
DirectoryGetPropertiesHeaders |
Defines headers for GetProperties operation. |
DirectoryGetPropertiesOptionalParams |
Optional Parameters. |
DirectoryItem |
A listed directory item. |
DirectoryListFilesAndDirectoriesSegmentHeaders |
Defines headers for ListFilesAndDirectoriesSegment operation. |
DirectoryListFilesAndDirectoriesSegmentOptionalParams |
Optional Parameters. |
DirectoryListHandlesHeaders |
Defines headers for ListHandles operation. |
DirectoryListHandlesOptionalParams |
Optional Parameters. |
DirectorySetMetadataHeaders |
Defines headers for SetMetadata operation. |
DirectorySetMetadataOptionalParams |
Optional Parameters. |
DirectorySetPropertiesHeaders |
Defines headers for SetProperties operation. |
DirectorySetPropertiesOptionalParams |
Optional Parameters. |
FileAbortCopyHeaders |
Defines headers for AbortCopy operation. |
FileAbortCopyOptionalParams |
Optional Parameters. |
FileCreateHeaders |
Defines headers for Create operation. |
FileCreateOptionalParams |
Optional Parameters. |
FileDeleteHeaders |
Defines headers for Delete operation. |
FileDeleteMethodOptionalParams |
Optional Parameters. |
FileDownloadHeaders |
Defines headers for Download operation. |
FileDownloadOptionalParams |
Optional Parameters. |
FileForceCloseHandlesHeaders |
Defines headers for ForceCloseHandles operation. |
FileForceCloseHandlesOptionalParams |
Optional Parameters. |
FileGetPropertiesHeaders |
Defines headers for GetProperties operation. |
FileGetPropertiesOptionalParams |
Optional Parameters. |
FileGetRangeListHeaders |
Defines headers for GetRangeList operation. |
FileGetRangeListOptionalParams |
Optional Parameters. |
FileHTTPHeaders |
Additional parameters for a set of operations, such as: File_create, File_setHTTPHeaders. |
FileItem |
A listed file item. |
FileListHandlesHeaders |
Defines headers for ListHandles operation. |
FileListHandlesOptionalParams |
Optional Parameters. |
FileProperty |
File properties. |
FileSetHTTPHeadersHeaders |
Defines headers for SetHTTPHeaders operation. |
FileSetHTTPHeadersOptionalParams |
Optional Parameters. |
FileSetMetadataHeaders |
Defines headers for SetMetadata operation. |
FileSetMetadataOptionalParams |
Optional Parameters. |
FileStartCopyHeaders |
Defines headers for StartCopy operation. |
FileStartCopyOptionalParams |
Optional Parameters. |
FileUploadRangeFromURLHeaders |
Defines headers for UploadRangeFromURL operation. |
FileUploadRangeFromURLOptionalParams |
Optional Parameters. |
FileUploadRangeHeaders |
Defines headers for UploadRange operation. |
FileUploadRangeOptionalParams |
Optional Parameters. |
FilesAndDirectoriesListSegment |
Abstract for entries that can be listed from Directory. |
HandleItem |
A listed Azure Storage handle item. |
ListFilesAndDirectoriesSegmentResponse |
An enumeration of directories and files. |
ListHandlesResponse |
An enumeration of handles. |
ListSharesResponse |
An enumeration of shares. |
Metrics |
Storage Analytics metrics for file service. |
Permission |
Permission(a security descriptor) described in the Security Descriptor Definition Language(SDDL). |
Range |
An Azure Storage file range. |
RetentionPolicy |
The retention policy. |
ServiceGetPropertiesHeaders |
Defines headers for GetProperties operation. |
ServiceGetPropertiesOptionalParams |
Optional Parameters. |
ServiceListSharesSegmentHeaders |
Defines headers for ListSharesSegment operation. |
ServiceListSharesSegmentOptionalParams |
Optional Parameters. |
ServiceSetPropertiesHeaders |
Defines headers for SetProperties operation. |
ServiceSetPropertiesOptionalParams |
Optional Parameters. |
ShareCreateHeaders |
Defines headers for Create operation. |
ShareCreateOptionalParams |
Optional Parameters. |
ShareCreatePermissionHeaders |
Defines headers for CreatePermission operation. |
ShareCreatePermissionOptionalParams |
Optional Parameters. |
ShareCreateSnapshotHeaders |
Defines headers for CreateSnapshot operation. |
ShareCreateSnapshotOptionalParams |
Optional Parameters. |
ShareDeleteHeaders |
Defines headers for Delete operation. |
ShareDeleteMethodOptionalParams |
Optional Parameters. |
ShareGetAccessPolicyHeaders |
Defines headers for GetAccessPolicy operation. |
ShareGetAccessPolicyOptionalParams |
Optional Parameters. |
ShareGetPermissionHeaders |
Defines headers for GetPermission operation. |
ShareGetPermissionOptionalParams |
Optional Parameters. |
ShareGetPropertiesHeaders |
Defines headers for GetProperties operation. |
ShareGetPropertiesOptionalParams |
Optional Parameters. |
ShareGetStatisticsHeaders |
Defines headers for GetStatistics operation. |
ShareGetStatisticsOptionalParams |
Optional Parameters. |
ShareItem |
A listed Azure Storage share item. |
ShareProperties |
Properties of a share. |
ShareSetAccessPolicyHeaders |
Defines headers for SetAccessPolicy operation. |
ShareSetAccessPolicyOptionalParams |
Optional Parameters. |
ShareSetMetadataHeaders |
Defines headers for SetMetadata operation. |
ShareSetMetadataOptionalParams |
Optional Parameters. |
ShareSetQuotaHeaders |
Defines headers for SetQuota operation. |
ShareSetQuotaOptionalParams |
Optional Parameters. |
ShareStats |
Stats for the share. |
SignedIdentifier |
Signed identifier. |
SourceModifiedAccessConditions |
Additional parameters for uploadRangeFromURL operation. |
StorageError |
An interface representing StorageError. |
StorageServiceProperties |
Storage service properties. |
IDownloadFromAzureFileOptions |
Option interface for DownloadAzurefileToBuffer. |
IUploadToAzureFileOptions |
Option interface for uploadFileToAzureFile and uploadSeekableStreamToAzureFile. |
IUploadStreamToAzureFileOptions |
Option interface for uploadStreamToAzureFile. |
IFileAndDirectoryCreateCommonOptions | |
IFileAndDirectorySetPropertiesCommonOptions | |
IFileHTTPHeaders | |
IMetadata | |
IRetriableReadableStreamOptions |
Type Aliases
FileDownloadResponse |
Contains response data for the download operation. |
FileGetRangeListResponse |
Contains response data for the getRangeList operation. |
ShareGetAccessPolicyResponse |
Contains response data for the getAccessPolicy operation. |
ShareGetStatisticsResponse |
Contains response data for the getStatistics operation. |
CredentialPolicyCreator |
A factory function that creates a new CredentialPolicy that uses the provided nextPolicy. |
CopyStatusType |
Defines values for CopyStatusType. Possible values include: 'pending', 'success', 'aborted', 'failed' |
DeleteSnapshotsOptionType |
Defines values for DeleteSnapshotsOptionType. Possible values include: 'include' |
DirectoryCreateResponse |
Contains response data for the create operation. |
DirectoryDeleteResponse |
Contains response data for the deleteMethod operation. |
DirectoryForceCloseHandlesResponse |
Contains response data for the forceCloseHandles operation. |
DirectoryGetPropertiesResponse |
Contains response data for the getProperties operation. |
DirectoryListFilesAndDirectoriesSegmentResponse |
Contains response data for the listFilesAndDirectoriesSegment operation. |
DirectoryListHandlesResponse |
Contains response data for the listHandles operation. |
DirectorySetMetadataResponse |
Contains response data for the setMetadata operation. |
DirectorySetPropertiesResponse |
Contains response data for the setProperties operation. |
FileAbortCopyResponse |
Contains response data for the abortCopy operation. |
FileCreateResponse |
Contains response data for the create operation. |
FileDeleteResponse |
Contains response data for the deleteMethod operation. |
FileForceCloseHandlesResponse |
Contains response data for the forceCloseHandles operation. |
FileGetPropertiesResponse |
Contains response data for the getProperties operation. |
FileListHandlesResponse |
Contains response data for the listHandles operation. |
FileRangeWriteType |
Defines values for FileRangeWriteType. Possible values include: 'update', 'clear' |
FileSetHTTPHeadersResponse |
Contains response data for the setHTTPHeaders operation. |
FileSetMetadataResponse |
Contains response data for the setMetadata operation. |
FileStartCopyResponse |
Contains response data for the startCopy operation. |
FileType |
Defines values for FileType. Possible values include: 'File' |
FileUploadRangeFromURLResponse |
Contains response data for the uploadRangeFromURL operation. |
FileUploadRangeResponse |
Contains response data for the uploadRange operation. |
ListSharesIncludeType |
Defines values for ListSharesIncludeType. Possible values include: 'snapshots', 'metadata' |
ServiceGetPropertiesResponse |
Contains response data for the getProperties operation. |
ServiceListSharesSegmentResponse |
Contains response data for the listSharesSegment operation. |
ServiceSetPropertiesResponse |
Contains response data for the setProperties operation. |
ShareCreatePermissionResponse |
Contains response data for the createPermission operation. |
ShareCreateResponse |
Contains response data for the create operation. |
ShareCreateSnapshotResponse |
Contains response data for the createSnapshot operation. |
ShareDeleteResponse |
Contains response data for the deleteMethod operation. |
ShareGetPermissionResponse |
Contains response data for the getPermission operation. |
ShareGetPropertiesResponse |
Contains response data for the getProperties operation. |
ShareSetAccessPolicyResponse |
Contains response data for the setAccessPolicy operation. |
ShareSetMetadataResponse |
Contains response data for the setMetadata operation. |
ShareSetQuotaResponse |
Contains response data for the setQuota operation. |
StorageErrorCode |
Defines values for StorageErrorCode. Possible values include: 'AccountAlreadyExists', 'AccountBeingCreated', 'AccountIsDisabled', 'AuthenticationFailed', 'AuthorizationFailure', 'ConditionHeadersNotSupported', 'ConditionNotMet', 'EmptyMetadataKey', 'InsufficientAccountPermissions', 'InternalError', 'InvalidAuthenticationInfo', 'InvalidHeaderValue', 'InvalidHttpVerb', 'InvalidInput', 'InvalidMd5', 'InvalidMetadata', 'InvalidQueryParameterValue', 'InvalidRange', 'InvalidResourceName', 'InvalidUri', 'InvalidXmlDocument', 'InvalidXmlNodeValue', 'Md5Mismatch', 'MetadataTooLarge', 'MissingContentLengthHeader', 'MissingRequiredQueryParameter', 'MissingRequiredHeader', 'MissingRequiredXmlNode', 'MultipleConditionHeadersNotSupported', 'OperationTimedOut', 'OutOfRangeInput', 'OutOfRangeQueryParameterValue', 'RequestBodyTooLarge', 'ResourceTypeMismatch', 'RequestUrlFailedToParse', 'ResourceAlreadyExists', 'ResourceNotFound', 'ServerBusy', 'UnsupportedHeader', 'UnsupportedXmlNode', 'UnsupportedQueryParameter', 'UnsupportedHttpVerb', 'CannotDeleteFileOrDirectory', 'ClientCacheFlushDelay', 'DeletePending', 'DirectoryNotEmpty', 'FileLockConflict', 'InvalidFileOrDirectoryPathName', 'ParentNotFound', 'ReadOnlyAttribute', 'ShareAlreadyExists', 'ShareBeingDeleted', 'ShareDisabled', 'ShareNotFound', 'SharingViolation', 'ShareSnapshotInProgress', 'ShareSnapshotCountExceeded', 'ShareSnapshotOperationNotSupported', 'ShareHasSnapshots', 'ContainerQuotaDowngradeNotAllowed' |
FileAttributesPreserveType |
Indicates keep existing file attributes unchanged. |
FilePermissionInheritType |
Indicates inherit file permission from the parent directory. |
FilePermissionPreserveType |
Indicates keep existing file permission value unchanged. |
TimeNowType |
Indicates setting as the time of the request. |
TimePreserveType |
Indicates keep existing time value unchanged. |
Operation |
Operation is an async function to be executed and managed by Batch. |
OutgoingHandler |
OutgoingHandler is an async function triggered by BufferScheduler. |
ReadableStreamGetter |
Enums
SASProtocol |
Protocols for generated SAS. |
RetryPolicyType |
RetryPolicy types. |
Functions
generate |
ONLY AVAILABLE IN NODE.JS RUNTIME. Generates a <xref:SASQueryParameters> object which contains all SAS query parameters needed to make an actual REST request. |
generate |
ONLY AVAILABLE IN NODE.JS RUNTIME. Creates an instance of SASQueryParameters. Only accepts required settings needed to create a SAS. For optional settings please set corresponding properties directly, such as permissions, startTime and identifier. WARNING: When identifier is not provided, permissions and expiryTime are required. You MUST assign value to identifier or expiryTime & permissions manually if you initial with this constructor. |
ip |
Generate IPRange format string. For example: "8.8.8.8" or "1.1.1.1-255.255.255.255" |
range |
Generate a range string. For example: "bytes=255-" or "bytes=0-511" |
upload |
ONLY AVAILABLE IN BROWSERS. Uploads a browser Blob/File/ArrayBuffer/ArrayBufferView object to an Azure File. |
download |
ONLY AVAILABLE IN NODE.JS RUNTIME. Downloads an Azure file in parallel to a buffer. Offset and count are optional, pass 0 for both to download the entire file. |
upload |
ONLY AVAILABLE IN NODE.JS RUNTIME. Uploads a local file to an Azure file. |
upload |
ONLY AVAILABLE IN NODE.JS RUNTIME.
Uploads a Node.js Readable stream into an Azure file.
This method will try to create an Azure, then starts uploading chunk by chunk.
Size of chunk is defined by PERFORMANCE IMPROVEMENT TIPS:
|
file |
|
file |
|
file |
|
validate |
|
validate |
|
validate |
|
New |
A factory method used to generated a RetryPolicy factory. |
blob |
Convert a Browser Blob object into ArrayBuffer. |
append |
Append a string to URL path. Will remove duplicated "/" in front of the string when URL path ends with a "/". |
base64decode(string) | Base64 decode. |
base64encode(string) | Base64 encode. |
delay(number, Abort |
Delay specified time interval. |
escape |
Reserved URL characters must be properly escaped for Storage services like Blob or File. URL encode and escape strategy for JSv10 SDKsWhen customers pass a URL string into XXXURL classes constructor, the URL string may already be URL encoded or not. But before sending to Azure Storage server, the URL must be encoded. However, it's hard for a SDK to guess whether the URL string has been encoded or not. We have 2 potential strategies, and chose strategy two for the XXXURL constructors. Strategy One: Assume the customer URL string is not encoded, and always encode URL string in SDK.This is what legacy V2 SDK does, simple and works for most of the cases.
But this strategy will make it not possible to create a blob with "?" in it's name. Because when customer URL string is "http://account.blob.core.windows.net/con/blob?name", the "?name" will be treated as URL paramter instead of blob name. If customer URL string is "http://account.blob.core.windows.net/con/blob%3Fname", a blob named "blob%3Fname" will be created. V2 SDK doesn't have this issue because it doesn't allow customer pass in a full URL, it accepts a separate blob name and encodeURIComponent for it. We cannot accept a SDK cannot create a blob name with "?". So we implement strategy two: Strategy Two: SDK doesn't assume the URL has been encoded or not. It will just escape the special characters.This is what V10 Blob Go SDK does. It accepts a URL type in Go, and call url.EscapedPath() to escape the special chars unescaped.
This strategy gives us flexibility to create with any special characters. But "%" will be treated as a special characters, if the URL string is not encoded, there shouldn't a "%" in the URL string, otherwise the URL is not a valid URL. If customer needs to create a blob with "%" in it's blob name, use "%25" insead of "%". Just like above 3rd sample. And following URL strings are invalid:
Another special character is "?", use "%2F" to represent a blob name with "?" in a URL string. Strategy for containerName, blobName or other specific XXXName parameters in methods such as
|
get |
Get URL parameter by name. |
get |
Get URL path from an URL string. |
get |
Get URL query key value pairs from an URL string. |
pad |
String.prototype.padStart() |
set |
Set URL host. |
set |
Set URL parameter name and value. If name exists in URL parameters, old value will be replaced by name key. If not provide value, the parameter will be deleted. |
truncatedISO8061Date(Date, undefined | false | true) | Rounds a date off to seconds. |
stream |
Reads a readable stream into buffer. Fill the buffer from offset to end. |
Function Details
generateAccountSASQueryParameters(IAccountSASSignatureValues, SharedKeyCredential)
ONLY AVAILABLE IN NODE.JS RUNTIME. Generates a <xref:SASQueryParameters> object which contains all SAS query parameters needed to make an actual REST request.
function generateAccountSASQueryParameters(accountSASSignatureValues: IAccountSASSignatureValues, sharedKeyCredential: SharedKeyCredential)
Parameters
- accountSASSignatureValues
- IAccountSASSignatureValues
- sharedKeyCredential
- SharedKeyCredential
Returns
generateFileSASQueryParameters(IFileSASSignatureValues, SharedKeyCredential)
ONLY AVAILABLE IN NODE.JS RUNTIME. Creates an instance of SASQueryParameters.
Only accepts required settings needed to create a SAS. For optional settings please set corresponding properties directly, such as permissions, startTime and identifier.
WARNING: When identifier is not provided, permissions and expiryTime are required. You MUST assign value to identifier or expiryTime & permissions manually if you initial with this constructor.
function generateFileSASQueryParameters(fileSASSignatureValues: IFileSASSignatureValues, sharedKeyCredential: SharedKeyCredential)
Parameters
- fileSASSignatureValues
- IFileSASSignatureValues
- sharedKeyCredential
- SharedKeyCredential
Returns
ipRangeToString(IIPRange)
Generate IPRange format string. For example: "8.8.8.8" or "1.1.1.1-255.255.255.255"
function ipRangeToString(ipRange: IIPRange)
Parameters
- ipRange
- IIPRange
Returns
string
rangeToString(IRange)
Generate a range string. For example: "bytes=255-" or "bytes=0-511"
function rangeToString(iRange: IRange)
Parameters
- iRange
- IRange
Returns
string
uploadBrowserDataToAzureFile(Aborter, Blob | ArrayBuffer | ArrayBufferView, FileURL, IUploadToAzureFileOptions)
ONLY AVAILABLE IN BROWSERS. Uploads a browser Blob/File/ArrayBuffer/ArrayBufferView object to an Azure File.
function uploadBrowserDataToAzureFile(aborter: Aborter, browserData: Blob | ArrayBuffer | ArrayBufferView, fileURL: FileURL, options?: IUploadToAzureFileOptions)
Parameters
- aborter
- Aborter
Create a new Aborter instance with Aborter.none or Aborter.timeout(), goto documents of Aborter for more examples about request cancellation
- browserData
-
Blob | ArrayBuffer | ArrayBufferView
Blob, File, ArrayBuffer or ArrayBufferView
- fileURL
- FileURL
- options
- IUploadToAzureFileOptions
Returns
Promise<void>
downloadAzureFileToBuffer(Aborter, Buffer, FileURL, number, undefined | number, IDownloadFromAzureFileOptions)
ONLY AVAILABLE IN NODE.JS RUNTIME. Downloads an Azure file in parallel to a buffer. Offset and count are optional, pass 0 for both to download the entire file.
function downloadAzureFileToBuffer(aborter: Aborter, buffer: Buffer, fileURL: FileURL, offset: number, count?: undefined | number, options?: IDownloadFromAzureFileOptions)
Parameters
- aborter
- Aborter
Create a new Aborter instance with Aborter.none or Aborter.timeout(), goto documents of Aborter for more examples about request cancellation
- buffer
-
Buffer
Buffer to be fill, must have length larger than count
- fileURL
- FileURL
A FileURL object
- offset
-
number
From which position of the Azure File to download
- count
-
undefined | number
- options
- IDownloadFromAzureFileOptions
Returns
Promise<void>
uploadFileToAzureFile(Aborter, string, FileURL, IUploadToAzureFileOptions)
ONLY AVAILABLE IN NODE.JS RUNTIME. Uploads a local file to an Azure file.
function uploadFileToAzureFile(aborter: Aborter, filePath: string, fileURL: FileURL, options?: IUploadToAzureFileOptions)
Parameters
- aborter
- Aborter
Create a new Aborter instance with Aborter.none or Aborter.timeout(), goto documents of Aborter for more examples about request cancellation
- filePath
-
string
Full path of local file
- fileURL
- FileURL
FileURL
- options
- IUploadToAzureFileOptions
Returns
Promise<void>
uploadStreamToAzureFile(Aborter, Readable, number, FileURL, number, number, IUploadStreamToAzureFileOptions)
ONLY AVAILABLE IN NODE.JS RUNTIME.
Uploads a Node.js Readable stream into an Azure file.
This method will try to create an Azure, then starts uploading chunk by chunk.
Size of chunk is defined by bufferSize
parameter.
Please make sure potential size of stream doesn't exceed file size.
PERFORMANCE IMPROVEMENT TIPS:
- Input stream highWaterMark is better to set a same value with bufferSize parameter, which will avoid Buffer.concat() operations.
function uploadStreamToAzureFile(aborter: Aborter, stream: Readable, size: number, fileURL: FileURL, bufferSize: number, maxBuffers: number, options?: IUploadStreamToAzureFileOptions)
Parameters
- aborter
- Aborter
Create a new Aborter instance with Aborter.none or Aborter.timeout(), goto documents of Aborter for more examples about request cancellation
- stream
-
Readable
Node.js Readable stream. Must be less or equal than file size.
- size
-
number
Size of file to be created. Maxium size allowed is 1TB. If this value is larger than stream size, there will be empty bytes in file tail.
- fileURL
- FileURL
A FileURL instance
- bufferSize
-
number
Size of every buffer allocated in bytes, also the chunk/range size during the uploaded file. Size must be > 0 and <= 4 * 1024 * 1024 (4MB)
- maxBuffers
-
number
Max buffers will allocate during uploading, positive correlation with max uploading concurrency
- options
- IUploadStreamToAzureFileOptions
Returns
Promise<void>
fileAttributesToString(FileSystemAttributes | FileAttributesPreserveType)
function fileAttributesToString(fileAttributes: FileSystemAttributes | FileAttributesPreserveType)
Parameters
- fileAttributes
Returns
string
fileCreationTimeToString(Date | TimeNowType | TimePreserveType)
function fileCreationTimeToString(time: Date | TimeNowType | TimePreserveType)
Parameters
- time
-
Date | TimeNowType | TimePreserveType
Returns
string
fileLastWriteTimeToString(Date | TimeNowType | TimePreserveType)
function fileLastWriteTimeToString(time: Date | TimeNowType | TimePreserveType)
Parameters
- time
-
Date | TimeNowType | TimePreserveType
Returns
string
validateAndSetDefaultsForFileAndDirectoryCreateCommonOptions(IFileAndDirectoryCreateCommonOptions)
function validateAndSetDefaultsForFileAndDirectoryCreateCommonOptions(options: IFileAndDirectoryCreateCommonOptions)
Parameters
Returns
validateAndSetDefaultsForFileAndDirectorySetPropertiesCommonOptions(IFileAndDirectorySetPropertiesCommonOptions)
function validateAndSetDefaultsForFileAndDirectorySetPropertiesCommonOptions(options: IFileAndDirectorySetPropertiesCommonOptions)
Parameters
Returns
validateFilePermissionOptions(undefined | string, undefined | string)
function validateFilePermissionOptions(filePermission?: undefined | string, filePermissionKey?: undefined | string)
Parameters
- filePermission
-
undefined | string
- filePermissionKey
-
undefined | string
NewRetryPolicyFactory(IRetryOptions)
A factory method used to generated a RetryPolicy factory.
function NewRetryPolicyFactory(retryOptions?: IRetryOptions)
Parameters
- retryOptions
- IRetryOptions
Returns
RequestPolicyFactory
blobToArrayBuffer(Blob)
Convert a Browser Blob object into ArrayBuffer.
function blobToArrayBuffer(blob: Blob)
Parameters
- blob
-
Blob
Returns
Promise<ArrayBuffer>
appendToURLPath(string, string)
Append a string to URL path. Will remove duplicated "/" in front of the string when URL path ends with a "/".
function appendToURLPath(url: string, name: string)
Parameters
- url
-
string
Source URL string
- name
-
string
String to be appended to URL
Returns
string
An updated URL string
base64decode(string)
Base64 decode.
function base64decode(encodedString: string)
Parameters
- encodedString
-
string
Returns
string
base64encode(string)
Base64 encode.
function base64encode(content: string)
Parameters
- content
-
string
Returns
string
delay(number, AbortSignalLike, Error)
Delay specified time interval.
function delay(timeInMs: number, aborter?: AbortSignalLike, abortError?: Error)
Parameters
- timeInMs
-
number
- aborter
-
AbortSignalLike
- abortError
-
Error
Returns
Promise<unknown>
escapeURLPath(string)
Reserved URL characters must be properly escaped for Storage services like Blob or File.
URL encode and escape strategy for JSv10 SDKs
When customers pass a URL string into XXXURL classes constructor, the URL string may already be URL encoded or not. But before sending to Azure Storage server, the URL must be encoded. However, it's hard for a SDK to guess whether the URL string has been encoded or not. We have 2 potential strategies, and chose strategy two for the XXXURL constructors.
Strategy One: Assume the customer URL string is not encoded, and always encode URL string in SDK.
This is what legacy V2 SDK does, simple and works for most of the cases.
- When customer URL string is "http://account.blob.core.windows.net/con/b:", SDK will encode it to "http://account.blob.core.windows.net/con/b%3A" and send to server. A blob named "b:" will be created.
- When customer URL string is "http://account.blob.core.windows.net/con/b%3A", SDK will encode it to "http://account.blob.core.windows.net/con/b%253A" and send to server. A blob named "b%3A" will be created.
But this strategy will make it not possible to create a blob with "?" in it's name. Because when customer URL string is "http://account.blob.core.windows.net/con/blob?name", the "?name" will be treated as URL paramter instead of blob name. If customer URL string is "http://account.blob.core.windows.net/con/blob%3Fname", a blob named "blob%3Fname" will be created. V2 SDK doesn't have this issue because it doesn't allow customer pass in a full URL, it accepts a separate blob name and encodeURIComponent for it. We cannot accept a SDK cannot create a blob name with "?". So we implement strategy two:
Strategy Two: SDK doesn't assume the URL has been encoded or not. It will just escape the special characters.
This is what V10 Blob Go SDK does. It accepts a URL type in Go, and call url.EscapedPath() to escape the special chars unescaped.
- When customer URL string is "http://account.blob.core.windows.net/con/b:", SDK will escape ":" like "http://account.blob.core.windows.net/con/b%3A" and send to server. A blob named "b:" will be created.
- When customer URL string is "http://account.blob.core.windows.net/con/b%3A", There is no special characters, so send "http://account.blob.core.windows.net/con/b%3A" to server. A blob named "b:" will be created.
- When customer URL string is "http://account.blob.core.windows.net/con/b%253A", There is no special characters, so send "http://account.blob.core.windows.net/con/b%253A" to server. A blob named "b%3A" will be created.
This strategy gives us flexibility to create with any special characters. But "%" will be treated as a special characters, if the URL string is not encoded, there shouldn't a "%" in the URL string, otherwise the URL is not a valid URL. If customer needs to create a blob with "%" in it's blob name, use "%25" insead of "%". Just like above 3rd sample. And following URL strings are invalid:
- "http://account.blob.core.windows.net/con/b%"
- "http://account.blob.core.windows.net/con/b%2"
- "http://account.blob.core.windows.net/con/b%G"
Another special character is "?", use "%2F" to represent a blob name with "?" in a URL string.
Strategy for containerName, blobName or other specific XXXName parameters in methods such as BlobURL.fromContainerURL(containerURL, blobName)
We will apply strategy one, and call encodeURIComponent for these parameters like blobName. Because what customers passes in is a plain name instead of a URL.
function escapeURLPath(url: string)
Parameters
- url
-
string
Returns
string
getURLParameter(string, string)
Get URL parameter by name.
function getURLParameter(url: string, name: string)
Parameters
- url
-
string
- name
-
string
Returns
string | string[] | undefined
getURLPath(string)
Get URL path from an URL string.
function getURLPath(url: string)
Parameters
- url
-
string
Source URL string
Returns
string | undefined
getURLQueries(string)
Get URL query key value pairs from an URL string.
function getURLQueries(url: string)
Parameters
- url
-
string
Returns
[key: string]: string
padStart(string, number, undefined | string)
String.prototype.padStart()
function padStart(currentString: string, targetLength: number, padString?: undefined | string)
Parameters
- currentString
-
string
- targetLength
-
number
- padString
-
undefined | string
Returns
string
setURLHost(string, string)
Set URL host.
function setURLHost(url: string, host: string)
Parameters
- url
-
string
Source URL string
- host
-
string
New host string
Returns
string
An updated URL string
setURLParameter(string, string, undefined | string)
Set URL parameter name and value. If name exists in URL parameters, old value will be replaced by name key. If not provide value, the parameter will be deleted.
function setURLParameter(url: string, name: string, value?: undefined | string)
Parameters
- url
-
string
Source URL string
- name
-
string
Parameter name
- value
-
undefined | string
Returns
string
An updated URL string
truncatedISO8061Date(Date, undefined | false | true)
Rounds a date off to seconds.
function truncatedISO8061Date(date: Date, withMilliseconds?: undefined | false | true)
Parameters
- date
-
Date
- withMilliseconds
-
undefined | false | true
Returns
string
Date string in ISO8061 format, with or without 7 milliseconds component
streamToBuffer(ReadableStream, Buffer, number, number, undefined | string)
Reads a readable stream into buffer. Fill the buffer from offset to end.
function streamToBuffer(stream: ReadableStream, buffer: Buffer, offset: number, end: number, encoding?: undefined | string)
Parameters
- stream
-
ReadableStream
A Node.js Readable stream
- buffer
-
Buffer
Buffer to be filled, length must >= offset
- offset
-
number
From which position in the buffer to be filled, inclusive
- end
-
number
To which position in the buffer to be filled, exclusive
- encoding
-
undefined | string
Returns
Promise<void>
Azure SDK for JavaScript