File class

Class representing a File.

Constructors

File(StorageClientContext)

Create a File.

Methods

abortCopy(string, FileAbortCopyOptionalParams, ServiceCallback<void>)
abortCopy(string, Models.FileAbortCopyOptionalParams)

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

abortCopy(string, ServiceCallback<void>)
create(number, string, string, string, FileCreateOptionalParams, ServiceCallback<void>)
create(number, string, string, string, Models.FileCreateOptionalParams)

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

create(number, string, string, string, ServiceCallback<void>)
deleteMethod(FileDeleteMethodOptionalParams, ServiceCallback<void>)
deleteMethod(Models.FileDeleteMethodOptionalParams)

removes the file from the storage account.

deleteMethod(ServiceCallback<void>)
download(FileDownloadOptionalParams, ServiceCallback<void>)
download(Models.FileDownloadOptionalParams)

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

download(ServiceCallback<void>)
forceCloseHandles(string, FileForceCloseHandlesOptionalParams, ServiceCallback<void>)
forceCloseHandles(string, Models.FileForceCloseHandlesOptionalParams)

Closes all handles open for given file

forceCloseHandles(string, ServiceCallback<void>)
getProperties(FileGetPropertiesOptionalParams, ServiceCallback<void>)
getProperties(Models.FileGetPropertiesOptionalParams)

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

getProperties(ServiceCallback<void>)
getRangeList(FileGetRangeListOptionalParams, ServiceCallback<Range[]>)
getRangeList(Models.FileGetRangeListOptionalParams)

Returns the list of valid ranges for a file.

getRangeList(ServiceCallback<Range[]>)
listHandles(FileListHandlesOptionalParams, ServiceCallback<ListHandlesResponse>)
listHandles(Models.FileListHandlesOptionalParams)

Lists handles for file

listHandles(ServiceCallback<ListHandlesResponse>)
setHTTPHeaders(string, string, string, FileSetHTTPHeadersOptionalParams, ServiceCallback<void>)
setHTTPHeaders(string, string, string, Models.FileSetHTTPHeadersOptionalParams)

Sets HTTP headers on the file.

setHTTPHeaders(string, string, string, ServiceCallback<void>)
setMetadata(FileSetMetadataOptionalParams, ServiceCallback<void>)
setMetadata(Models.FileSetMetadataOptionalParams)

Updates user-defined metadata for the specified file.

setMetadata(ServiceCallback<void>)
startCopy(string, FileStartCopyOptionalParams, ServiceCallback<void>)
startCopy(string, Models.FileStartCopyOptionalParams)

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

startCopy(string, ServiceCallback<void>)
uploadRange(string, Models.FileRangeWriteType, number, FileUploadRangeOptionalParams, ServiceCallback<void>)
uploadRange(string, Models.FileRangeWriteType, number, Models.FileUploadRangeOptionalParams)

Upload a range of bytes to a file.

uploadRange(string, Models.FileRangeWriteType, number, ServiceCallback<void>)
uploadRangeFromURL(string, string, string, number, FileUploadRangeFromURLOptionalParams, ServiceCallback<void>)
uploadRangeFromURL(string, string, string, number, Models.FileUploadRangeFromURLOptionalParams)

Upload a range of bytes to a file where the contents are read from a URL.

uploadRangeFromURL(string, string, string, number, ServiceCallback<void>)

Constructor Details

File(StorageClientContext)

Create a File.

new File(client: StorageClientContext)

Parameters

client
StorageClientContext

Reference to the service client.

Method Details

abortCopy(string, FileAbortCopyOptionalParams, ServiceCallback<void>)

function abortCopy(copyId: string, options: FileAbortCopyOptionalParams, callback: ServiceCallback<void>)

Parameters

copyId

string

The copy identifier provided in the x-ms-copy-id header of the original Copy File operation.

options
FileAbortCopyOptionalParams

The optional parameters

callback

ServiceCallback<void>

The callback

abortCopy(string, Models.FileAbortCopyOptionalParams)

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

function abortCopy(copyId: string, options?: Models.FileAbortCopyOptionalParams)

Parameters

copyId

string

The copy identifier provided in the x-ms-copy-id header of the original Copy File operation.

options
Models.FileAbortCopyOptionalParams

Returns

Promise<Models.FileAbortCopyResponse>

Promise<Models.FileAbortCopyResponse>

abortCopy(string, ServiceCallback<void>)

function abortCopy(copyId: string, callback: ServiceCallback<void>)

Parameters

copyId

string

The copy identifier provided in the x-ms-copy-id header of the original Copy File operation.

callback

ServiceCallback<void>

The callback

create(number, string, string, string, FileCreateOptionalParams, ServiceCallback<void>)

function create(fileContentLength: number, fileAttributes: string, fileCreationTime: string, fileLastWriteTime: string, options: FileCreateOptionalParams, callback: ServiceCallback<void>)

Parameters

fileContentLength

number

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

fileAttributes

string

If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file and ‘Directory’ for directory. ‘None’ can also be specified as default.

fileCreationTime

string

Creation time for the file/directory.

fileLastWriteTime

string

Last write time for the file/directory.

options
FileCreateOptionalParams

The optional parameters

callback

ServiceCallback<void>

The callback

create(number, string, string, string, Models.FileCreateOptionalParams)

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

function create(fileContentLength: number, fileAttributes: string, fileCreationTime: string, fileLastWriteTime: string, options?: Models.FileCreateOptionalParams)

Parameters

fileContentLength

number

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

fileAttributes

string

If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file and ‘Directory’ for directory. ‘None’ can also be specified as default.

fileCreationTime

string

Creation time for the file/directory.

fileLastWriteTime

string

Last write time for the file/directory.

options
Models.FileCreateOptionalParams

Returns

Promise<Models.FileCreateResponse>

Promise<Models.FileCreateResponse>

create(number, string, string, string, ServiceCallback<void>)

function create(fileContentLength: number, fileAttributes: string, fileCreationTime: string, fileLastWriteTime: string, callback: ServiceCallback<void>)

Parameters

fileContentLength

number

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

fileAttributes

string

If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file and ‘Directory’ for directory. ‘None’ can also be specified as default.

fileCreationTime

string

Creation time for the file/directory.

fileLastWriteTime

string

Last write time for the file/directory.

callback

ServiceCallback<void>

The callback

deleteMethod(FileDeleteMethodOptionalParams, ServiceCallback<void>)

function deleteMethod(options: FileDeleteMethodOptionalParams, callback: ServiceCallback<void>)

Parameters

options
FileDeleteMethodOptionalParams

The optional parameters

callback

ServiceCallback<void>

The callback

deleteMethod(Models.FileDeleteMethodOptionalParams)

removes the file from the storage account.

function deleteMethod(options?: Models.FileDeleteMethodOptionalParams)

Parameters

options
Models.FileDeleteMethodOptionalParams

Returns

Promise<Models.FileDeleteResponse>

Promise<Models.FileDeleteResponse>

deleteMethod(ServiceCallback<void>)

function deleteMethod(callback: ServiceCallback<void>)

Parameters

callback

ServiceCallback<void>

The callback

download(FileDownloadOptionalParams, ServiceCallback<void>)

function download(options: FileDownloadOptionalParams, callback: ServiceCallback<void>)

Parameters

options
FileDownloadOptionalParams

The optional parameters

callback

ServiceCallback<void>

The callback

download(Models.FileDownloadOptionalParams)

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

function download(options?: Models.FileDownloadOptionalParams)

Parameters

options
Models.FileDownloadOptionalParams

Returns

Promise<Models.FileDownloadResponse>

Promise<Models.FileDownloadResponse>

download(ServiceCallback<void>)

function download(callback: ServiceCallback<void>)

Parameters

callback

ServiceCallback<void>

The callback

forceCloseHandles(string, FileForceCloseHandlesOptionalParams, ServiceCallback<void>)

function forceCloseHandles(handleId: string, options: FileForceCloseHandlesOptionalParams, callback: ServiceCallback<void>)

Parameters

handleId

string

Specifies handle ID opened on the file or directory to be closed. Asterix (‘*’) is a wildcard that specifies all handles.

options
FileForceCloseHandlesOptionalParams

The optional parameters

callback

ServiceCallback<void>

The callback

forceCloseHandles(string, Models.FileForceCloseHandlesOptionalParams)

Closes all handles open for given file

function forceCloseHandles(handleId: string, options?: Models.FileForceCloseHandlesOptionalParams)

Parameters

handleId

string

Specifies handle ID opened on the file or directory to be closed. Asterix (‘*’) is a wildcard that specifies all handles.

options
Models.FileForceCloseHandlesOptionalParams

Returns

Promise<Models.FileForceCloseHandlesResponse>

Promise<Models.FileForceCloseHandlesResponse>

forceCloseHandles(string, ServiceCallback<void>)

function forceCloseHandles(handleId: string, callback: ServiceCallback<void>)

Parameters

handleId

string

Specifies handle ID opened on the file or directory to be closed. Asterix (‘*’) is a wildcard that specifies all handles.

callback

ServiceCallback<void>

The callback

getProperties(FileGetPropertiesOptionalParams, ServiceCallback<void>)

function getProperties(options: FileGetPropertiesOptionalParams, callback: ServiceCallback<void>)

Parameters

options
FileGetPropertiesOptionalParams

The optional parameters

callback

ServiceCallback<void>

The callback

getProperties(Models.FileGetPropertiesOptionalParams)

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

function getProperties(options?: Models.FileGetPropertiesOptionalParams)

Parameters

options
Models.FileGetPropertiesOptionalParams

Returns

Promise<Models.FileGetPropertiesResponse>

Promise<Models.FileGetPropertiesResponse>

getProperties(ServiceCallback<void>)

function getProperties(callback: ServiceCallback<void>)

Parameters

callback

ServiceCallback<void>

The callback

getRangeList(FileGetRangeListOptionalParams, ServiceCallback<Range[]>)

function getRangeList(options: FileGetRangeListOptionalParams, callback: ServiceCallback<Range[]>)

Parameters

options
FileGetRangeListOptionalParams

The optional parameters

callback

ServiceCallback<Range[]>

The callback

getRangeList(Models.FileGetRangeListOptionalParams)

Returns the list of valid ranges for a file.

function getRangeList(options?: Models.FileGetRangeListOptionalParams)

Parameters

options
Models.FileGetRangeListOptionalParams

Returns

Promise<Models.FileGetRangeListResponse>

Promise<Models.FileGetRangeListResponse>

getRangeList(ServiceCallback<Range[]>)

function getRangeList(callback: ServiceCallback<Range[]>)

Parameters

callback

ServiceCallback<Range[]>

The callback

listHandles(FileListHandlesOptionalParams, ServiceCallback<ListHandlesResponse>)

function listHandles(options: FileListHandlesOptionalParams, callback: ServiceCallback<ListHandlesResponse>)

Parameters

options
FileListHandlesOptionalParams

The optional parameters

callback

ServiceCallback<ListHandlesResponse>

The callback

listHandles(Models.FileListHandlesOptionalParams)

Lists handles for file

function listHandles(options?: Models.FileListHandlesOptionalParams)

Parameters

options
Models.FileListHandlesOptionalParams

Returns

Promise<Models.FileListHandlesResponse>

Promise<Models.FileListHandlesResponse>

listHandles(ServiceCallback<ListHandlesResponse>)

function listHandles(callback: ServiceCallback<ListHandlesResponse>)

Parameters

callback

ServiceCallback<ListHandlesResponse>

The callback

setHTTPHeaders(string, string, string, FileSetHTTPHeadersOptionalParams, ServiceCallback<void>)

function setHTTPHeaders(fileAttributes: string, fileCreationTime: string, fileLastWriteTime: string, options: FileSetHTTPHeadersOptionalParams, callback: ServiceCallback<void>)

Parameters

fileAttributes

string

If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file and ‘Directory’ for directory. ‘None’ can also be specified as default.

fileCreationTime

string

Creation time for the file/directory.

fileLastWriteTime

string

Last write time for the file/directory.

options
FileSetHTTPHeadersOptionalParams

The optional parameters

callback

ServiceCallback<void>

The callback

setHTTPHeaders(string, string, string, Models.FileSetHTTPHeadersOptionalParams)

Sets HTTP headers on the file.

function setHTTPHeaders(fileAttributes: string, fileCreationTime: string, fileLastWriteTime: string, options?: Models.FileSetHTTPHeadersOptionalParams)

Parameters

fileAttributes

string

If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file and ‘Directory’ for directory. ‘None’ can also be specified as default.

fileCreationTime

string

Creation time for the file/directory.

fileLastWriteTime

string

Last write time for the file/directory.

options
Models.FileSetHTTPHeadersOptionalParams

Returns

Promise<Models.FileSetHTTPHeadersResponse>

Promise<Models.FileSetHTTPHeadersResponse>

setHTTPHeaders(string, string, string, ServiceCallback<void>)

function setHTTPHeaders(fileAttributes: string, fileCreationTime: string, fileLastWriteTime: string, callback: ServiceCallback<void>)

Parameters

fileAttributes

string

If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file and ‘Directory’ for directory. ‘None’ can also be specified as default.

fileCreationTime

string

Creation time for the file/directory.

fileLastWriteTime

string

Last write time for the file/directory.

callback

ServiceCallback<void>

The callback

setMetadata(FileSetMetadataOptionalParams, ServiceCallback<void>)

function setMetadata(options: FileSetMetadataOptionalParams, callback: ServiceCallback<void>)

Parameters

options
FileSetMetadataOptionalParams

The optional parameters

callback

ServiceCallback<void>

The callback

setMetadata(Models.FileSetMetadataOptionalParams)

Updates user-defined metadata for the specified file.

function setMetadata(options?: Models.FileSetMetadataOptionalParams)

Parameters

options
Models.FileSetMetadataOptionalParams

Returns

Promise<Models.FileSetMetadataResponse>

Promise<Models.FileSetMetadataResponse>

setMetadata(ServiceCallback<void>)

function setMetadata(callback: ServiceCallback<void>)

Parameters

callback

ServiceCallback<void>

The callback

startCopy(string, FileStartCopyOptionalParams, ServiceCallback<void>)

function startCopy(copySource: string, options: FileStartCopyOptionalParams, callback: ServiceCallback<void>)

Parameters

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.

options
FileStartCopyOptionalParams

The optional parameters

callback

ServiceCallback<void>

The callback

startCopy(string, Models.FileStartCopyOptionalParams)

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

function startCopy(copySource: string, options?: Models.FileStartCopyOptionalParams)

Parameters

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.

options
Models.FileStartCopyOptionalParams

Returns

Promise<Models.FileStartCopyResponse>

Promise<Models.FileStartCopyResponse>

startCopy(string, ServiceCallback<void>)

function startCopy(copySource: string, callback: ServiceCallback<void>)

Parameters

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.

callback

ServiceCallback<void>

The callback

uploadRange(string, Models.FileRangeWriteType, number, FileUploadRangeOptionalParams, ServiceCallback<void>)

function uploadRange(range: string, fileRangeWrite: Models.FileRangeWriteType, contentLength: number, options: FileUploadRangeOptionalParams, callback: ServiceCallback<void>)

Parameters

range

string

Specifies the range of bytes to be written. Both the start and end of the range must be specified. For an update operation, the range can be up to 4 MB in size. For a clear operation, the range can be up to the value of the file's full size. The File service accepts only a single byte range for the Range and 'x-ms-range' headers, and the byte range must be specified in the following format: bytes=startByte-endByte.

fileRangeWrite
Models.FileRangeWriteType

Specify one of the following options: - Update: Writes the bytes specified by the request body into the specified range. The Range and Content-Length headers must match to perform the update. - Clear: Clears the specified range and releases the space used in storage for that range. To clear a range, set the Content-Length header to zero, and set the Range header to a value that indicates the range to clear, up to maximum file size. Possible values include: 'update', 'clear'

contentLength

number

Specifies the number of bytes being transmitted in the request body. When the x-ms-write header is set to clear, the value of this header must be set to zero.

options
FileUploadRangeOptionalParams

The optional parameters

callback

ServiceCallback<void>

The callback

uploadRange(string, Models.FileRangeWriteType, number, Models.FileUploadRangeOptionalParams)

Upload a range of bytes to a file.

function uploadRange(range: string, fileRangeWrite: Models.FileRangeWriteType, contentLength: number, options?: Models.FileUploadRangeOptionalParams)

Parameters

range

string

Specifies the range of bytes to be written. Both the start and end of the range must be specified. For an update operation, the range can be up to 4 MB in size. For a clear operation, the range can be up to the value of the file's full size. The File service accepts only a single byte range for the Range and 'x-ms-range' headers, and the byte range must be specified in the following format: bytes=startByte-endByte.

fileRangeWrite
Models.FileRangeWriteType

Specify one of the following options: - Update: Writes the bytes specified by the request body into the specified range. The Range and Content-Length headers must match to perform the update. - Clear: Clears the specified range and releases the space used in storage for that range. To clear a range, set the Content-Length header to zero, and set the Range header to a value that indicates the range to clear, up to maximum file size. Possible values include: 'update', 'clear'

contentLength

number

Specifies the number of bytes being transmitted in the request body. When the x-ms-write header is set to clear, the value of this header must be set to zero.

options
Models.FileUploadRangeOptionalParams

Returns

Promise<Models.FileUploadRangeResponse>

Promise<Models.FileUploadRangeResponse>

uploadRange(string, Models.FileRangeWriteType, number, ServiceCallback<void>)

function uploadRange(range: string, fileRangeWrite: Models.FileRangeWriteType, contentLength: number, callback: ServiceCallback<void>)

Parameters

range

string

Specifies the range of bytes to be written. Both the start and end of the range must be specified. For an update operation, the range can be up to 4 MB in size. For a clear operation, the range can be up to the value of the file's full size. The File service accepts only a single byte range for the Range and 'x-ms-range' headers, and the byte range must be specified in the following format: bytes=startByte-endByte.

fileRangeWrite
Models.FileRangeWriteType

Specify one of the following options: - Update: Writes the bytes specified by the request body into the specified range. The Range and Content-Length headers must match to perform the update. - Clear: Clears the specified range and releases the space used in storage for that range. To clear a range, set the Content-Length header to zero, and set the Range header to a value that indicates the range to clear, up to maximum file size. Possible values include: 'update', 'clear'

contentLength

number

Specifies the number of bytes being transmitted in the request body. When the x-ms-write header is set to clear, the value of this header must be set to zero.

callback

ServiceCallback<void>

The callback

uploadRangeFromURL(string, string, string, number, FileUploadRangeFromURLOptionalParams, ServiceCallback<void>)

function uploadRangeFromURL(range: string, copySource: string, sourceRange: string, contentLength: number, options: FileUploadRangeFromURLOptionalParams, callback: ServiceCallback<void>)

Parameters

range

string

Writes data to the specified byte range in the file.

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.

sourceRange

string

Bytes of source data in the specified range.

contentLength

number

Specifies the number of bytes being transmitted in the request body. When the x-ms-write header is set to clear, the value of this header must be set to zero.

options
FileUploadRangeFromURLOptionalParams

The optional parameters

callback

ServiceCallback<void>

The callback

uploadRangeFromURL(string, string, string, number, Models.FileUploadRangeFromURLOptionalParams)

Upload a range of bytes to a file where the contents are read from a URL.

function uploadRangeFromURL(range: string, copySource: string, sourceRange: string, contentLength: number, options?: Models.FileUploadRangeFromURLOptionalParams)

Parameters

range

string

Writes data to the specified byte range in the file.

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.

sourceRange

string

Bytes of source data in the specified range.

contentLength

number

Specifies the number of bytes being transmitted in the request body. When the x-ms-write header is set to clear, the value of this header must be set to zero.

options
Models.FileUploadRangeFromURLOptionalParams

Returns

Promise<Models.FileUploadRangeFromURLResponse>

Promise<Models.FileUploadRangeFromURLResponse>

uploadRangeFromURL(string, string, string, number, ServiceCallback<void>)

function uploadRangeFromURL(range: string, copySource: string, sourceRange: string, contentLength: number, callback: ServiceCallback<void>)

Parameters

range

string

Writes data to the specified byte range in the file.

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.

sourceRange

string

Bytes of source data in the specified range.

contentLength

number

Specifies the number of bytes being transmitted in the request body. When the x-ms-write header is set to clear, the value of this header must be set to zero.

callback

ServiceCallback<void>

The callback