Creates an instance of DirectoryClient.
A URL string pointing to Azure Storage file directory, such as "https://myaccount.file.core.windows.net/myshare/mydirectory". You can append a SAS if using AnonymousCredential, such as "https://myaccount.file.core.windows.net/myshare/mydirectory?sasString". This method accepts an encoded URL or non-encoded URL pointing to a directory. Encoded URL string will NOT be escaped twice, only special characters in URL path will be escaped. However, if a directory name includes %, directory name must be encoded in the URL. Such as a directory named "mydir%", the URL should be "https://myaccount.file.core.windows.net/myshare/mydir%25".
Creates an instance of DirectoryClient.
A URL string pointing to Azure Storage file directory, such as "https://myaccount.file.core.windows.net/myshare/mydirectory". You can append a SAS if using AnonymousCredential, such as "https://myaccount.file.core.windows.net/myshare/mydirectory?sasString". This method accepts an encoded URL or non-encoded URL pointing to a directory. Encoded URL string will NOT be escaped twice, only special characters in URL path will be escaped. However, if a directory name includes %, directory name must be encoded in the URL. Such as a directory named "mydir%", the URL should be "https://myaccount.file.core.windows.net/myshare/mydir%25".
Call newPipeline() to create a default pipeline, or provide a customized pipeline.
StorageClient is a reference to protocol layer operations entry, which is generated by AutoRest generator.
URL string value.
The name of the directory
The full path of the directory
The share name corresponding to this directory client
Creates a new directory under the specified share or parent directory.
Response data for the Directory operation.
Creates a new file or replaces a file under this directory. Note it only initializes the file with no content.
Specifies the maximum size in bytes for the file, up to 1 TB.
} File creation response data and the corresponding file client.
Creates a new directory under the specified share or parent directory if it does not already exists. If the directory already exists, it is not modified.
Creates a new subdirectory under this directory.
} Directory create response data and the corresponding DirectoryClient instance.
Removes the specified empty directory. Note that the directory must be empty before it can be deleted.
Response data for the Directory Delete operation.
Removes the specified file under this directory 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)
Name of the file to delete
File deletion response data.
Removes the specified empty directory if it exists. Note that the directory must be empty before it can be deleted.
Removes the specified empty sub directory under this directory. Note that the directory must be empty before it can be deleted.
Directory deletion response data.
Returns true if the specified directory exists; false otherwise.
NOTE: use this function with care since an existing directory might be deleted by other clients or applications. Vice versa new directories might be added by other clients or applications after this function completes.
Force close all handles for a directory.
Force close a specific handle for a directory.
Specific handle ID, cannot be asterisk "*". Use forceCloseHandlesSegment() to close all handles.
Creates a ShareDirectoryClient object for a sub directory.
A subdirectory name
The ShareDirectoryClient object for the given subdirectory name.
Creates a ShareFileClient object.
A file name.
A new ShareFileClient object for the given file name.
Returns all system properties for the specified directory, and can also be used to check the existence of a directory. The data returned does not include the files in the directory or any subdirectories.
Response data for the Directory Get Properties operation.
Returns an async iterable iterator to list all the files and directories under the specified account.
.byPage() returns an async iterable iterator to list the files and directories in pages.
Example using for await
syntax:
let i = 1;
for await (const entity of directoryClient.listFilesAndDirectories()) {
if (entity.kind === "directory") {
console.log(`${i++} - directory\t: ${entity.name}`);
} else {
console.log(`${i++} - file\t: ${entity.name}`);
}
}
Example using iter.next()
:
let i = 1;
let iter = directoryClient.listFilesAndDirectories();
let entity = await iter.next();
while (!entity.done) {
if (entity.value.kind === "directory") {
console.log(`${i++} - directory\t: ${entity.value.name}`);
} else {
console.log(`${i++} - file\t: ${entity.value.name}`);
}
entity = await iter.next();
}
Example using byPage()
:
// passing optional maxPageSize in the page settings
let i = 1;
for await (const response of directoryClient
.listFilesAndDirectories()
.byPage({ maxPageSize: 20 })) {
for (const fileItem of response.segment.fileItems) {
console.log(`${i++} - file\t: ${fileItem.name}`);
}
for (const dirItem of response.segment.directoryItems) {
console.log(`${i++} - directory\t: ${dirItem.name}`);
}
}
Example using paging with a marker:
let i = 1;
let iterator = directoryClient.listFilesAndDirectories().byPage({ maxPageSize: 3 });
let response = (await iterator.next()).value;
// Prints 3 file and directory names
for (const fileItem of response.segment.fileItems) {
console.log(`${i++} - file\t: ${fileItem.name}`);
}
for (const dirItem of response.segment.directoryItems) {
console.log(`${i++} - directory\t: ${dirItem.name}`);
}
// Gets next marker
let dirMarker = response.continuationToken;
// Passing next marker as continuationToken
iterator = directoryClient
.listFilesAndDirectories()
.byPage({ continuationToken: dirMarker, maxPageSize: 4 });
response = (await iterator.next()).value;
// Prints 10 file and directory names
for (const fileItem of response.segment.fileItems) {
console.log(`${i++} - file\t: ${fileItem.name}`);
}
for (const dirItem of response.segment.directoryItems) {
console.log(`${i++} - directory\t: ${dirItem.name}`);
}
& FileItem | { kind: "directory" } , DirectoryListFilesAndDirectoriesSegmentResponse>} An asyncIterableIterator that supports paging.
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.
Example using for await
syntax:
let i = 1;
let iter = dirClient.listHandles();
for await (const handle of iter) {
console.log(`Handle ${i++}: ${handle.path}, opened time ${handle.openTime}, clientIp ${handle.clientIp}`);
}
Example using iter.next()
:
let i = 1;
let iter = dirClient.listHandles();
let handleItem = await iter.next();
while (!handleItem.done) {
console.log(`Handle ${i++}: ${handleItem.value.path}, opened time ${handleItem.value.openTime}, clientIp ${handleItem.value.clientIp}`);
handleItem = await iter.next();
}
Example using byPage()
:
// passing optional maxPageSize in the page settings
let i = 1;
for await (const response of dirClient.listHandles({ recursive: true }).byPage({ maxPageSize: 20 })) {
if (response.handleList) {
for (const handle of response.handleList) {
console.log(`Handle ${i++}: ${handle.path}, opened time ${handle.openTime}, clientIp ${handle.clientIp}`);
}
}
}
Example using paging with a marker:
let i = 1;
let iterator = dirClient.listHandles().byPage({ maxPageSize: 2 });
let response = await iterator.next();
// Prints 2 handles
if (response.value.handleList) {
for (const handle of response.value.handleList) {
console.log(`Handle ${i++}: ${handle.path}, opened time ${handle.openTime}, clientIp ${handle.clientIp}`);
}
}
// Gets next marker
let marker = response.value.continuationToken;
// Passing next marker as continuationToken
console.log(` continuation`);
iterator = dirClient.listHandles().byPage({ continuationToken: marker, maxPageSize: 10 });
response = await iterator.next();
// Prints 2 more handles assuming you have more than four directory/files opened
if (!response.done && response.value.handleList) {
for (const handle of response.value.handleList) {
console.log(`Handle ${i++}: ${handle.path}, opened time ${handle.openTime}, clientIp ${handle.clientIp}`);
}
}
An asyncIterableIterator that supports paging.
Updates user defined metadata for the specified directory.
Response data for the Directory Set Metadata operation.
Sets properties on the directory.
Generated using TypeDoc
A ShareDirectoryClient represents a URL to the Azure Storage directory allowing you to manipulate its files and directories.