FileURL class

A FileURL represents a URL to an Azure Storage file.

Extends

Constructors

FileURL(string, Pipeline)

Creates an instance of FileURL.

Inherited Properties

url

URL string value.

Methods

abortCopyFromURL(Aborter, string)

Aborts a pending Copy File operation, and leaves a destination file with zero length and full metadata.

See https://docs.microsoft.com/en-us/rest/api/storageservices/abort-copy-file

clearRange(Aborter, number, number)

Clears the specified range and releases the space used in storage for that range.

create(Aborter, number, IFileCreateOptions)

Creates a new file or replaces a file. Note it only initializes the file with no content.

See https://docs.microsoft.com/en-us/rest/api/storageservices/create-file

delete(Aborter)

Removes the file from the storage account. When a file is successfully deleted, it is immediately removed from the storage account's index and is no longer accessible to clients. The file's data is later removed from the service during garbage collection.

Delete File will fail with status code 409 (Conflict) and error code SharingViolation if the file is open on an SMB client.

Delete File is not supported on a share snapshot, which is a read-only copy of a share. An attempt to perform this operation on a share snapshot will fail with 400 (InvalidQueryParameterValue)

See https://docs.microsoft.com/en-us/rest/api/storageservices/delete-file2

download(Aborter, number, number, IFileDownloadOptions)

Reads or downloads a file from the system, including its metadata and properties.

  • In Node.js, data returns in a Readable stream readableStreamBody
  • In browsers, data returns in a promise blobBody

See https://docs.microsoft.com/en-us/rest/api/storageservices/get-file

forceCloseHandle(Aborter, string)

Force close a specific handle for a file.

See https://docs.microsoft.com/en-us/rest/api/storageservices/force-close-handles

forceCloseHandlesSegment(Aborter, string)

Force close all handles for a file.

See https://docs.microsoft.com/en-us/rest/api/storageservices/force-close-handles

fromDirectoryURL(DirectoryURL, string)

Creates a FileURL object from a DirectoryURL object.

getProperties(Aborter)

Returns all user-defined metadata, standard HTTP properties, and system properties for the file. It does not return the content of the file.

See https://docs.microsoft.com/en-us/rest/api/storageservices/get-file-properties

getRangeList(Aborter, IFileGetRangeListOptions)

Returns the list of valid ranges for a file.

listHandlesSegment(Aborter, string, IFileListHandlesSegmentOptions)

Lists handles for a file.

See https://docs.microsoft.com/en-us/rest/api/storageservices/list-handles

resize(Aborter, number)

Resize file.

See https://docs.microsoft.com/en-us/rest/api/storageservices/set-file-properties

setHTTPHeaders(Aborter, IFileHTTPHeaders)

Sets HTTP headers on the file.

If no option provided, or no value provided for the file HTTP headers in the options, these file HTTP headers without a value will be cleared.

See https://docs.microsoft.com/en-us/rest/api/storageservices/set-file-properties

setMetadata(Aborter, IMetadata)

Updates user-defined metadata for the specified file.

If no metadata defined in the option parameter, the file metadata will be removed.

See https://docs.microsoft.com/en-us/rest/api/storageservices/set-file-metadata

setProperties(Aborter, IFileProperties)

Sets properties on the file.

See https://docs.microsoft.com/en-us/rest/api/storageservices/set-file-properties

startCopyFromURL(Aborter, string, IFileStartCopyOptions)

Copies a blob or file to a destination file within the storage account.

uploadRange(Aborter, HttpRequestBody, number, number, IFileUploadRangeOptions)

Upload a range of bytes to a file. Both the start and count of the range must be specified. The range can be up to 4 MB in size.

uploadRangeFromURL(Aborter, string, number, number, number)

Upload a range of bytes to a file where the contents are read from a another file's URL. The range can be up to 4 MB in size.

withPipeline(Pipeline)

Creates a new FileURL object identical to the source but with the specified request policy pipeline.

Inherited Methods

newPipeline(Credential, INewPipelineOptions)

A static method used to create a new Pipeline object with Credential provided.

Constructor Details

FileURL(string, Pipeline)

Creates an instance of FileURL.

new FileURL(url: string, pipeline: Pipeline)

Parameters

url

string

A URL string pointing to Azure Storage file, such as "https://myaccount.file.core.windows.net/myshare/mydirectory/file". You can append a SAS if using AnonymousCredential, such as "https://myaccount.file.core.windows.net/myshare/mydirectory/file?sasString". This method accepts an encoded URL or non-encoded URL pointing to a file. Encoded URL string will NOT be escaped twice, only special characters in URL path will be escaped. However, if a file or directory name includes %, file or directory name must be encoded in the URL. Such as a file named "myfile%", the URL should be "https://myaccount.file.core.windows.net/myshare/mydirectory/myfile%25".

pipeline
Pipeline

Call StorageURL.newPipeline() to create a default pipeline, or provide a customized pipeline.

Inherited Property Details

url

URL string value.

url: string

Property Value

string

Inherited From StorageURL.url

Method Details

abortCopyFromURL(Aborter, string)

Aborts a pending Copy File operation, and leaves a destination file with zero length and full metadata.

See https://docs.microsoft.com/en-us/rest/api/storageservices/abort-copy-file

function abortCopyFromURL(aborter: Aborter, copyId: string): Promise<FileAbortCopyResponse>

Parameters

aborter
Aborter

Create a new Aborter instance with Aborter.none or Aborter.timeout(), goto documents of Aborter for more examples about request cancellation

copyId

string

Returns

clearRange(Aborter, number, number)

Clears the specified range and releases the space used in storage for that range.

function clearRange(aborter: Aborter, offset: number, contentLength: number): Promise<FileUploadRangeResponse>

Parameters

aborter
Aborter

Create a new Aborter instance with Aborter.none or Aborter.timeout(), goto documents of Aborter for more examples about request cancellation

offset

number

contentLength

number

Returns

create(Aborter, number, IFileCreateOptions)

Creates a new file or replaces a file. Note it only initializes the file with no content.

See https://docs.microsoft.com/en-us/rest/api/storageservices/create-file

function create(aborter: Aborter, size: number, options?: IFileCreateOptions): Promise<FileCreateResponse>

Parameters

aborter
Aborter

Create a new Aborter instance with Aborter.none or Aborter.timeout(), goto documents of Aborter for more examples about request cancellation

size

number

Specifies the maximum size in bytes for the file, up to 1 TB.

Returns

delete(Aborter)

Removes the file from the storage account. When a file is successfully deleted, it is immediately removed from the storage account's index and is no longer accessible to clients. The file's data is later removed from the service during garbage collection.

Delete File will fail with status code 409 (Conflict) and error code SharingViolation if the file is open on an SMB client.

Delete File is not supported on a share snapshot, which is a read-only copy of a share. An attempt to perform this operation on a share snapshot will fail with 400 (InvalidQueryParameterValue)

See https://docs.microsoft.com/en-us/rest/api/storageservices/delete-file2

function delete(aborter: Aborter): Promise<FileDeleteResponse>

Parameters

aborter
Aborter

Create a new Aborter instance with Aborter.none or Aborter.timeout(), goto documents of Aborter for more examples about request cancellation

Returns

download(Aborter, number, number, IFileDownloadOptions)

Reads or downloads a file from the system, including its metadata and properties.

  • In Node.js, data returns in a Readable stream readableStreamBody
  • In browsers, data returns in a promise blobBody

See https://docs.microsoft.com/en-us/rest/api/storageservices/get-file

function download(aborter: Aborter, offset: number, count?: number, options?: IFileDownloadOptions): Promise<FileDownloadResponse>

Parameters

aborter
Aborter

Create a new Aborter instance with Aborter.none or Aborter.timeout(), goto documents of Aborter for more examples about request cancellation

offset

number

From which position of the file to download, >= 0

count

number

How much data to be downloaded, > 0. Will download to the end when undefined

Returns

forceCloseHandle(Aborter, string)

Force close a specific handle for a file.

See https://docs.microsoft.com/en-us/rest/api/storageservices/force-close-handles

function forceCloseHandle(aborter: Aborter, handleId: string): Promise<FileForceCloseHandlesResponse>

Parameters

aborter
Aborter

Create a new Aborter instance with Aborter.none or Aborter.timeout(), goto documents of Aborter for more examples about request cancellation

handleId

string

Specific handle ID, cannot be asterisk "*". Use forceCloseHandlesSegment() to close all handles.

Returns

forceCloseHandlesSegment(Aborter, string)

Force close all handles for a file.

See https://docs.microsoft.com/en-us/rest/api/storageservices/force-close-handles

function forceCloseHandlesSegment(aborter: Aborter, marker?: string): Promise<FileForceCloseHandlesResponse>

Parameters

aborter
Aborter

Create a new Aborter instance with Aborter.none or Aborter.timeout(), goto documents of Aborter for more examples about request cancellation

marker

string

Optional. A string value that identifies the position of handles that will be closed with the next force close handles operation. The operation returns a marker value within the response body if there are more handles to close. The marker value may then be used in a subsequent call to close the next set of handles.

Returns

fromDirectoryURL(DirectoryURL, string)

Creates a FileURL object from a DirectoryURL object.

static function fromDirectoryURL(directoryURL: DirectoryURL, fileName: string): FileURL

Parameters

directoryURL
DirectoryURL

A DirectoryURL object

fileName

string

A file name

Returns

getProperties(Aborter)

Returns all user-defined metadata, standard HTTP properties, and system properties for the file. It does not return the content of the file.

See https://docs.microsoft.com/en-us/rest/api/storageservices/get-file-properties

function getProperties(aborter: Aborter): Promise<FileGetPropertiesResponse>

Parameters

aborter
Aborter

Create a new Aborter instance with Aborter.none or Aborter.timeout(), goto documents of Aborter for more examples about request cancellation

Returns

getRangeList(Aborter, IFileGetRangeListOptions)

Returns the list of valid ranges for a file.

function getRangeList(aborter: Aborter, options?: IFileGetRangeListOptions): Promise<FileGetRangeListResponse>

Parameters

aborter
Aborter

Create a new Aborter instance with Aborter.none or Aborter.timeout(), goto documents of Aborter for more examples about request cancellation

Returns

listHandlesSegment(Aborter, string, IFileListHandlesSegmentOptions)

Lists handles for a file.

See https://docs.microsoft.com/en-us/rest/api/storageservices/list-handles

function listHandlesSegment(aborter: Aborter, marker?: string, options?: IFileListHandlesSegmentOptions): Promise<FileListHandlesResponse>

Parameters

aborter
Aborter

Create a new Aborter instance with Aborter.none or Aborter.timeout(), goto documents of Aborter for more examples about request cancellation

marker

string

Optional. A string value that identifies the portion of the list to be returned with the next list handles operation. The operation returns a marker value within the response body if the list returned was not complete. The marker value may then be used in a subsequent call to request the next set of list items.

Returns

resize(Aborter, number)

Resize file.

See https://docs.microsoft.com/en-us/rest/api/storageservices/set-file-properties

function resize(aborter: Aborter, length: number): Promise<FileSetHTTPHeadersResponse>

Parameters

aborter
Aborter

Create a new Aborter instance with Aborter.none or Aborter.timeout(), goto documents of Aborter for more examples about request cancellation

length

number

Resizes a file to the specified size in bytes. If the specified byte value is less than the current size of the file, then all ranges above the specified byte value are cleared.

Returns

setHTTPHeaders(Aborter, IFileHTTPHeaders)

Sets HTTP headers on the file.

If no option provided, or no value provided for the file HTTP headers in the options, these file HTTP headers without a value will be cleared.

See https://docs.microsoft.com/en-us/rest/api/storageservices/set-file-properties

function setHTTPHeaders(aborter: Aborter, fileHTTPHeaders?: IFileHTTPHeaders): Promise<FileSetHTTPHeadersResponse>

Parameters

aborter
Aborter

Create a new Aborter instance with Aborter.none or Aborter.timeout(), goto documents of Aborter for more examples about request cancellation

fileHTTPHeaders

IFileHTTPHeaders

Returns

setMetadata(Aborter, IMetadata)

Updates user-defined metadata for the specified file.

If no metadata defined in the option parameter, the file metadata will be removed.

See https://docs.microsoft.com/en-us/rest/api/storageservices/set-file-metadata

function setMetadata(aborter: Aborter, metadata?: IMetadata): Promise<FileSetMetadataResponse>

Parameters

aborter
Aborter

Create a new Aborter instance with Aborter.none or Aborter.timeout(), goto documents of Aborter for more examples about request cancellation

metadata

IMetadata

If no metadata provided, all existing directory metadata will be removed

Returns

setProperties(Aborter, IFileProperties)

Sets properties on the file.

See https://docs.microsoft.com/en-us/rest/api/storageservices/set-file-properties

function setProperties(aborter: Aborter, properties?: IFileProperties): Promise<ISetPropertiesResponse>

Parameters

aborter
Aborter

Create a new Aborter instance with Aborter.none or Aborter.timeout(), goto documents of Aborter for more examples about request cancellation

properties
IFileProperties

Returns

startCopyFromURL(Aborter, string, IFileStartCopyOptions)

Copies a blob or file to a destination file within the storage account.

function startCopyFromURL(aborter: Aborter, copySource: string, options?: IFileStartCopyOptions): Promise<FileStartCopyResponse>

Parameters

aborter
Aborter

Create a new Aborter instance with Aborter.none or Aborter.timeout(), goto documents of Aborter for more examples about request cancellation

copySource

string

Specifies the URL of the source file or blob, up to 2 KB in length. To copy a file to another file within the same storage account, you may use Shared Key to authenticate the source file. If you are copying a file from another storage account, or if you are copying a blob from the same storage account or another storage account, then you must authenticate the source file or blob using a shared access signature. If the source is a public blob, no authentication is required to perform the copy operation. A file in a share snapshot can also be specified as a copy source.

Returns

uploadRange(Aborter, HttpRequestBody, number, number, IFileUploadRangeOptions)

Upload a range of bytes to a file. Both the start and count of the range must be specified. The range can be up to 4 MB in size.

function uploadRange(aborter: Aborter, body: HttpRequestBody, offset: number, contentLength: number, options?: IFileUploadRangeOptions): Promise<FileUploadRangeResponse>

Parameters

aborter
Aborter

Create a new Aborter instance with Aborter.none or Aborter.timeout(), goto documents of Aborter for more examples about request cancellation.

body
HttpRequestBody

Blob, string, ArrayBuffer, ArrayBufferView or a function which returns a new Readable stream whose offset is from data source beginning.

offset

number

Offset position of the destination Azure File to upload.

contentLength

number

Length of body in bytes. Use Buffer.byteLength() to calculate body length for a string including non non-Base64/Hex-encoded characters.

Returns

uploadRangeFromURL(Aborter, string, number, number, number)

Upload a range of bytes to a file where the contents are read from a another file's URL. The range can be up to 4 MB in size.

function uploadRangeFromURL(aborter: Aborter, sourceURL: string, sourceOffset: number, destOffset: number, count: number): Promise<FileUploadRangeFromURLResponse>

Parameters

aborter
Aborter

Create a new Aborter instance with Aborter.none or Aborter.timeout(), goto documents of Aborter for more examples about request cancellation.

sourceURL

string

Specify a URL to the copy source, Shared Access Signature(SAS) maybe needed for authentication.

sourceOffset

number

The source offset to copy from. Pass 0 to copy from the beginning of source file.

destOffset

number

Offset of destination file.

count

number

Number of bytes to be uploaded from source file.

Returns

withPipeline(Pipeline)

Creates a new FileURL object identical to the source but with the specified request policy pipeline.

function withPipeline(pipeline: Pipeline): FileURL

Parameters

pipeline
Pipeline

Returns

Inherited Method Details

newPipeline(Credential, INewPipelineOptions)

A static method used to create a new Pipeline object with Credential provided.

static function newPipeline(credential: Credential, pipelineOptions?: INewPipelineOptions): Pipeline

Parameters

credential
Credential

Such as AnonymousCredential, SharedKeyCredential.

pipelineOptions
INewPipelineOptions

Optional. Options.

Returns

A new Pipeline object.

Inherited From StorageURL.newPipeline