Creates an instance of ShareFileClient.
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".
Such as AnonymousCredential or StorageSharedKeyCredential. If not specified, AnonymousCredential is used.
Optional. Options to configure the HTTP pipeline.
Creates an instance of ShareFileClient.
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".
Call newPipeline() to create a default pipeline, or provide a customized pipeline.
Credential in the pipleline to authenticate requests to the service, such as AnonymousCredential, StorageSharedKeyCredential. Initialized to an AnonymousCredential if not able to retrieve it from the pipeline.
Request policy pipeline.
StorageClient is a reference to protocol layer operations entry, which is generated by AutoRest generator.
URL string value.
The name of the file
The full path of the file
The share name corresponding to this file client
Aborts a pending Copy File operation, and leaves a destination file with zero length and full metadata.
Id of the Copy File operation to abort.
Options to File Abort Copy From URL operation.
Clears the specified range and releases the space used in storage for that range.
-
-
Options to File Clear Range operation.
Creates a new file or replaces a file. Note it only initializes the file with no content.
Specifies the maximum size in bytes for the file, up to 4 TB.
Options to File Create operation.
Response data for the File Create operation.
Example usage:
const content = "Hello world!";
// Create the file
await fileClient.create(content.length);
console.log("Created file successfully!");
// Then upload data to the file
await fileClient.uploadRange(content, 0, content.length);
console.log("Updated file successfully!")
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)
Options to File Delete operation.
Response data for the File Delete operation.
Removes the file from the storage account if it exists. 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)
-
Reads or downloads a file from the system, including its metadata and properties.
readableStreamBody
contentAsBlob
From which position of the file to download, greater than or equal to 0
How much data to be downloaded, greater than 0. Will download to the end when undefined
Options to File Download operation.
Response data for the File Download operation.
Example usage (Node.js):
// Download a file to a string
const downloadFileResponse = await fileClient.download();
console.log(
"Downloaded file content:",
(await streamToBuffer(downloadFileResponse.readableStreamBody)).toString()}
);
// A helper method used to read a Node.js readable stream into string
async function streamToBuffer(readableStream) {
return new Promise((resolve, reject) => {
const chunks = [];
readableStream.on("data", (data) => {
chunks.push(data instanceof Buffer ? data : Buffer.from(data));
});
readableStream.on("end", () => {
resolve(Buffer.concat(chunks));
});
readableStream.on("error", reject);
});
}
Example usage (browsers):
// Download a file to a string
const downloadFileResponse = await fileClient.download(0);
console.log(
"Downloaded file content:",
await blobToString(await downloadFileResponse.blobBody)}
);
// A helper method used to convert a browser Blob into string.
export async function blobToString(blob: Blob): Promise<string> {
const fileReader = new FileReader();
return new Promise<string>((resolve, reject) => {
fileReader.onloadend = (ev: any) => {
resolve(ev.target!.result);
};
fileReader.onerror = reject;
fileReader.readAsText(blob);
});
}
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.
Warning: Buffers can only support files up to about one gigabyte on 32-bit systems or about two gigabytes on 64-bit systems due to limitations of Node.js/V8. For files larger than this size, consider downloadToFile.
Buffer to be fill, must have length larger than count
From which position of the Azure File to download
How much data to be downloaded. Will download to the end when passing undefined
-
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
Warning: Buffers can only support files up to about one gigabyte on 32-bit systems or about two gigabytes on 64-bit systems due to limitations of Node.js/V8. For files larger than this size, consider downloadToFile.
From which position of the Azure file to download
How much data to be downloaded. Will download to the end when passing undefined
-
ONLY AVAILABLE IN NODE.JS RUNTIME.
Downloads an Azure Blob to a local file. Fails if the the given file path already exits. Offset and count are optional, pass 0 and undefined respectively to download the entire blob.
-
From which position of the block blob to download.
How much data to be downloaded. Will download to the end when passing undefined.
Options to Blob download options.
The response data for blob download operation, but with readableStreamBody set to undefined since its content is already read and written into a local file at the specified path.
Returns true if the specified file exists; false otherwise.
NOTE: use this function with care since an existing file might be deleted by other clients or applications. Vice versa new files might be added by other clients or applications after this function completes.
options to Exists operation.
Force close all handles for a file.
Options to force close handles operation.
Force close a specific handle for a file.
Specific handle ID, cannot be asterisk "*". Use forceCloseAllHandles() to close all handles.
Only available for clients constructed with a shared key credential.
Generates a Service Shared Access Signature (SAS) URI based on the client properties and parameters passed in. The SAS is signed by the shared key credential of the client.
Optional parameters.
The SAS URI consisting of the URI to the resource represented by this client, followed by the generated SAS token.
Returns all user-defined metadata, standard HTTP properties, and system properties for the file. It does not return the content of the file.
Options to File Get Properties operation.
Response data for the File Get Properties operation.
Returns the list of valid ranges for a file.
Options to File Get range List operation.
Returns the list of ranges that differ between a previous share snapshot and this file.
The previous snapshot parameter is an opaque DateTime value that specifies the previous share snapshot to compare with.
-
Get a ShareLeaseClient that manages leases on the file.
Initial proposed lease Id.
A new ShareLeaseClient object for managing leases on the file.
Returns an async iterable iterator to list all the handles. under the specified account.
.byPage() returns an async iterable iterator to list the handles in pages.
Options to list handles operation.
An asyncIterableIterator that supports paging.
Resize file.
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.
Options to File Resize operation.
Response data for the File Set HTTP Headers operation.
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.
Options to File Set HTTP Headers operation.
Response data for the File Set HTTP Headers operation.
Updates user-defined metadata for the specified file.
If no metadata defined in the option parameter, the file metadata will be removed.
If no metadata provided, all existing directory metadata will be removed
Options to File Set Metadata operation.
Response data for the File Set Metadata operation.
Sets properties on the file.
File properties. For file HTTP headers(e.g. Content-Type), if no values are provided, existing HTTP headers will be removed. For other file properties(e.g. fileAttributes), if no values are provided, existing values will be preserved.
Copies a blob or file to a destination file within the storage account.
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 to File Start Copy operation.
Creates a new Azure File or replaces an existing Azure File, and then uploads a Buffer(Node)/Blob/ArrayBuffer/ArrayBufferView to it.
Buffer(Node), Blob, ArrayBuffer or ArrayBufferView
-
ONLY AVAILABLE IN NODE.JS RUNTIME.
Creates a new Azure File or replaces an existing Azure File, and then uploads a local file to it.
Full path of local file
-
Upload a range of bytes to a file. This operation can only be called on an existing file. It won't change the size, properties or metadata of the file. Both the start and count of the range must be specified. The range can be up to 4 MB in size.
Blob, string, ArrayBuffer, ArrayBufferView or a function which returns a new Readable stream whose offset is from data source beginning.
Offset position of the destination Azure File to upload.
Length of body in bytes. Use Buffer.byteLength() to calculate body length for a string including non non-Base64/Hex-encoded characters.
Options to File Upload Range operation.
Response data for the File Upload Range operation.
Example usage:
const content = "Hello world!";
// Create the file
await fileClient.create(content.length);
console.log("Created file successfully!");
// Then upload data to the file
await fileClient.uploadRange(content, 0, content.length);
console.log("Updated file successfully!")
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.
Specify a URL to the copy source, Shared Access Signature(SAS) maybe needed for authentication.
The source offset to copy from. Pass 0 to copy from the beginning of source file.
Offset of destination file.
Number of bytes to be uploaded from source file.
Options to configure File - Upload Range from URL operation.
ONLY AVAILABLE IN NODE.JS RUNTIME.
Accepts a Node.js Readable stream factory, and uploads in blocks to an Azure File. The Readable stream factory must returns a Node.js Readable stream starting from the offset defined. The offset is the offset in the Azure file to be uploaded.
Returns a Node.js Readable stream starting from the offset defined
Size of the Azure file
-
ONLY AVAILABLE IN BROWSERS.
Uploads a browser Blob object to an Azure file. Requires a blobFactory as the data source, which need to return a Blob object with the offset and size provided.
-
-
-
ONLY AVAILABLE IN NODE.JS RUNTIME.
Creates a new Azure File or replaces an existing Azure File, and then uploads a Node.js Readable stream into it.
This method will try to create an Azure File, 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:
Node.js Readable stream. Must be less or equal than file size.
Size of file to be created. Maximum size allowed is 4 TB. If this value is larger than stream size, there will be empty bytes in file tail.
Size of every buffer allocated in bytes, also the chunk/range size during the uploaded file. Size must be greater than 0 and lesser than or equal to 4 * 1024 * 1024 (4MB)
Max buffers will allocate during uploading, positive correlation with max uploading concurrency
-
Creates a new ShareFileClient object identical to the source but with the specified share snapshot timestamp. Provide "" will remove the snapshot and return a URL to the base ShareFileClient.
The share snapshot timestamp.
A new ShareFileClient object identical to the source but with the specified share snapshot timestamp.
Generated using TypeDoc
A ShareFileClient represents a URL to an Azure Storage file.