Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ShareDirectoryClient

Package version

A ShareDirectoryClient represents a URL to the Azure Storage directory allowing you to manipulate its files and directories.

export
class

ShareDirectoryClient

Hierarchy

Index

Constructors

constructor

Properties

accountName

accountName: string

Protected storageClientContext

storageClientContext: StorageClientContext

StorageClient is a reference to protocol layer operations entry, which is generated by AutoRest generator.

type

{StorageClientContext}

memberof

StorageClient

url

url: string

URL string value.

type

{string}

memberof

StorageClient

Accessors

path

  • get path(): string

shareName

  • get shareName(): string

Methods

create

createFile

  • createFile(fileName: string, size: number, options?: FileCreateOptions): Promise<object>

createSubdirectory

delete

deleteFile

  • 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)

    see

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

    memberof

    ShareDirectoryClient

    Parameters

    • fileName: string

      Name of the file to delete

    • Default value options: FileDeleteOptions = {}

    Returns Promise<FileDeleteResponse>

    File deletion response data.

deleteSubdirectory

forceCloseAllHandles

forceCloseHandle

getDirectoryClient

getFileClient

getProperties

listFilesAndDirectories

  • 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
      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
      // Generator syntax .next()
      let i = 1;
      let iter = await 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
      // Example for .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
      // Passing marker as an argument (similar to the previous example)
      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}`);
      }
    memberof

    ShareDirectoryClient

    Parameters

    Returns PagedAsyncIterableIterator<object & FileItem | object & DirectoryItem, DirectoryListFilesAndDirectoriesSegmentResponse>

    & FileItem | { kind: "directory" } , DirectoryListFilesAndDirectoriesSegmentResponse>} An asyncIterableIterator that supports paging.

listHandles

  • 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
      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
      // Generator syntax .next()
      let i = 1;
      let iter = await 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
      // Example for .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
      // Passing marker as an argument (similar to the previous example)
      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}`);
        }
      }
    memberof

    ShareDirectoryClient

    Parameters

    Returns PagedAsyncIterableIterator<HandleItem, DirectoryListHandlesResponse>

    An asyncIterableIterator that supports paging.

setMetadata

setProperties

Generated using TypeDoc