Delen via


ShareDirectoryClient class

Een ShareDirectoryClient vertegenwoordigt een URL naar de Azure Storage-map, zodat u de bestanden en mappen kunt bewerken.

Uitbreiding

StorageClient

Constructors

ShareDirectoryClient(string, Credential | TokenCredential, ShareClientOptions)

Hiermee maakt u een exemplaar van DirectoryClient.

ShareDirectoryClient(string, Pipeline, ShareClientConfig)

Hiermee maakt u een exemplaar van DirectoryClient.

Eigenschappen

name

De naam van de map

path

Het volledige pad van de map

shareName

De naam van de share die overeenkomt met deze directoryclient

Overgenomen eigenschappen

accountName
url

URL-tekenreekswaarde.

Methoden

create(DirectoryCreateOptions)

Hiermee maakt u een nieuwe map onder de opgegeven share of bovenliggende map.

Zie https://learn.microsoft.com/rest/api/storageservices/create-directory

createFile(string, number, FileCreateOptions)

Hiermee maakt u een nieuw bestand of vervangt u een bestand onder deze map. Houd er rekening mee dat het bestand alleen wordt geïnitialiseerd zonder inhoud.

Zie https://learn.microsoft.com/rest/api/storageservices/create-file

createIfNotExists(DirectoryCreateOptions)

Hiermee maakt u een nieuwe map onder de opgegeven share of bovenliggende map als deze nog niet bestaat. Als de map al bestaat, wordt deze niet gewijzigd.

Zie https://learn.microsoft.com/rest/api/storageservices/create-directory

createSubdirectory(string, DirectoryCreateOptions)

Hiermee maakt u een nieuwe submap onder deze map.

Zie https://learn.microsoft.com/rest/api/storageservices/create-directory

delete(DirectoryDeleteOptions)

Hiermee verwijdert u de opgegeven lege map. Houd er rekening mee dat de map leeg moet zijn voordat deze kan worden verwijderd.

Zie https://learn.microsoft.com/rest/api/storageservices/delete-directory

deleteFile(string, FileDeleteOptions)

Hiermee verwijdert u het opgegeven bestand onder deze map uit het opslagaccount. Wanneer een bestand is verwijderd, wordt het onmiddellijk verwijderd uit de index van het opslagaccount en is het niet meer toegankelijk voor clients. De gegevens van het bestand worden later uit de service verwijderd tijdens de garbagecollection.

Bestand verwijderen mislukt met statuscode 409 (Conflict) en foutcode SharingViolation als het bestand is geopend op een SMB-client.

Bestand verwijderen wordt niet ondersteund op een momentopname van een share. Dit is een alleen-lezen kopie van een share. Een poging om deze bewerking uit te voeren op een momentopname van een share mislukt met 400 (InvalidQueryParameterValue)

Zie https://learn.microsoft.com/rest/api/storageservices/delete-file2

deleteIfExists(DirectoryDeleteOptions)

Hiermee verwijdert u de opgegeven lege map als deze bestaat. Houd er rekening mee dat de map leeg moet zijn voordat deze kan worden verwijderd.

Zie https://learn.microsoft.com/rest/api/storageservices/delete-directory

deleteSubdirectory(string, DirectoryDeleteOptions)

Hiermee verwijdert u de opgegeven lege submap onder deze map. Houd er rekening mee dat de map leeg moet zijn voordat deze kan worden verwijderd.

Zie https://learn.microsoft.com/rest/api/storageservices/delete-directory

exists(DirectoryExistsOptions)

Retourneert waar als de opgegeven map bestaat; anders onwaar.

OPMERKING: gebruik deze functie met zorg omdat een bestaande map kan worden verwijderd door andere clients of toepassingen. Omgekeerd kunnen nieuwe mappen worden toegevoegd door andere clients of toepassingen nadat deze functie is voltooid.

forceCloseAllHandles(DirectoryForceCloseHandlesSegmentOptions)

Sluit alle ingangen voor een map af.

Zie https://learn.microsoft.com/rest/api/storageservices/force-close-handles

forceCloseHandle(string, DirectoryForceCloseHandlesOptions)

Sluit een specifieke ingang voor een map af.

Zie https://learn.microsoft.com/rest/api/storageservices/force-close-handles

getDirectoryClient(string)

Hiermee maakt u een ShareDirectoryClient-object voor een submap.

getFileClient(string)

Hiermee maakt u een ShareFileClient--object.

getProperties(DirectoryGetPropertiesOptions)

Retourneert alle systeemeigenschappen voor de opgegeven map en kan ook worden gebruikt om het bestaan van een map te controleren. De geretourneerde gegevens bevatten niet de bestanden in de map of submappen.

Zie https://learn.microsoft.com/rest/api/storageservices/get-directory-properties

listFilesAndDirectories(DirectoryListFilesAndDirectoriesOptions)

Retourneert een asynchrone iterator om alle bestanden en mappen onder het opgegeven account weer te geven.

.byPage() retourneert een asynchrone iterator om de bestanden en mappen in pagina's weer te geven.

Voorbeeld van for await syntaxis:

import { StorageSharedKeyCredential, ShareServiceClient } from "@azure/storage-file-share";

const account = "<account>";
const accountKey = "<accountkey>";

const credential = new StorageSharedKeyCredential(account, accountKey);
const serviceClient = new ShareServiceClient(
  `https://${account}.file.core.windows.net`,
  credential,
);

const shareName = "<share name>";
const directoryName = "<directory name>";
const directoryClient = serviceClient.getShareClient(shareName).getDirectoryClient(directoryName);

let i = 1;
for await (const item of directoryClient.listFilesAndDirectories()) {
  if (item.kind === "directory") {
    console.log(`${i} - directory\t: ${item.name}`);
  } else {
    console.log(`${i} - file\t: ${item.name}`);
  }
  i++;
}

Voorbeeld van iter.next():

import { StorageSharedKeyCredential, ShareServiceClient } from "@azure/storage-file-share";

const account = "<account>";
const accountKey = "<accountkey>";

const credential = new StorageSharedKeyCredential(account, accountKey);
const serviceClient = new ShareServiceClient(
  `https://${account}.file.core.windows.net`,
  credential,
);

const shareName = "<share name>";
const directoryName = "<directory name>";
const directoryClient = serviceClient.getShareClient(shareName).getDirectoryClient(directoryName);

let i = 1;
const iter = directoryClient.listFilesAndDirectories();
let { value, done } = await iter.next();
while (!done) {
  if (value.kind === "directory") {
    console.log(`${i} - directory\t: ${value.name}`);
  } else {
    console.log(`${i} - file\t: ${value.name}`);
  }
  ({ value, done } = await iter.next());
  i++;
}

Voorbeeld van byPage():

import { StorageSharedKeyCredential, ShareServiceClient } from "@azure/storage-file-share";

const account = "<account>";
const accountKey = "<accountkey>";

const credential = new StorageSharedKeyCredential(account, accountKey);
const serviceClient = new ShareServiceClient(
  `https://${account}.file.core.windows.net`,
  credential,
);

const shareName = "<share name>";
const directoryName = "<directory name>";
const directoryClient = serviceClient.getShareClient(shareName).getDirectoryClient(directoryName);

let i = 1;
for await (const response of directoryClient
  .listFilesAndDirectories()
  .byPage({ maxPageSize: 20 })) {
  console.log(`Page ${i++}:`);
  for (const item of response.segment.directoryItems) {
    console.log(`\tdirectory: ${item.name}`);
  }
  for (const item of response.segment.fileItems) {
    console.log(`\tfile: ${item.name}`);
  }
}

Voorbeeld van het gebruik van paging met een markering:

import { StorageSharedKeyCredential, ShareServiceClient } from "@azure/storage-file-share";

const account = "<account>";
const accountKey = "<accountkey>";

const credential = new StorageSharedKeyCredential(account, accountKey);
const serviceClient = new ShareServiceClient(
  `https://${account}.file.core.windows.net`,
  credential,
);

const shareName = "<share name>";
const directoryName = "<directory name>";
const directoryClient = serviceClient.getShareClient(shareName).getDirectoryClient(directoryName);

let iterator = directoryClient.listFilesAndDirectories().byPage({ maxPageSize: 2 });
let response = (await iterator.next()).value;

for await (const item of response.segment.directoryItems) {
  console.log(`\tdirectory: ${item.name}`);
}

for await (const item of response.segment.fileItems) {
  console.log(`\tfile: ${item.name}`);
}

// Gets next marker
let marker = response.continuationToken;

// Passing next marker as continuationToken
iterator = directoryClient
  .listFilesAndDirectories()
  .byPage({ continuationToken: marker, maxPageSize: 10 });
response = (await iterator.next()).value;

for await (const item of response.segment.directoryItems) {
  console.log(`\tdirectory: ${item.name}`);
}

for await (const item of response.segment.fileItems) {
  console.log(`\tfile: ${item.name}`);
}
listHandles(DirectoryListHandlesOptions)

Retourneert een asynchrone iterator om alle ingangen weer te geven. onder het opgegeven account.

.byPage() retourneert een asynchrone iterator om de ingangen in pagina's weer te geven.

Voorbeeld van for await syntaxis:

import { StorageSharedKeyCredential, ShareServiceClient } from "@azure/storage-file-share";

const account = "<account>";
const accountKey = "<accountkey>";

const credential = new StorageSharedKeyCredential(account, accountKey);
const serviceClient = new ShareServiceClient(
  `https://${account}.file.core.windows.net`,
  credential,
);

const shareName = "<share name>";
const directoryName = "<directory name>";
const directoryClient = serviceClient.getShareClient(shareName).getDirectoryClient(directoryName);

for await (const handle of directoryClient.listHandles()) {
  console.log(`Handle: ${handle.handleId}`);
}

Voorbeeld van iter.next():

import { StorageSharedKeyCredential, ShareServiceClient } from "@azure/storage-file-share";

const account = "<account>";
const accountKey = "<accountkey>";

const credential = new StorageSharedKeyCredential(account, accountKey);
const serviceClient = new ShareServiceClient(
  `https://${account}.file.core.windows.net`,
  credential,
);

const shareName = "<share name>";
const directoryName = "<directory name>";
const directoryClient = serviceClient.getShareClient(shareName).getDirectoryClient(directoryName);

const handleIter = directoryClient.listHandles();
let { value, done } = await handleIter.next();
while (!done) {
  console.log(`Handle: ${value.handleId}`);
  ({ value, done } = await handleIter.next());
}

Voorbeeld van byPage():

import { StorageSharedKeyCredential, ShareServiceClient } from "@azure/storage-file-share";

const account = "<account>";
const accountKey = "<accountkey>";

const credential = new StorageSharedKeyCredential(account, accountKey);
const serviceClient = new ShareServiceClient(
  `https://${account}.file.core.windows.net`,
  credential,
);

const shareName = "<share name>";
const directoryName = "<directory name>";
const directoryClient = serviceClient.getShareClient(shareName).getDirectoryClient(directoryName);

let i = 1;
for await (const response of directoryClient.listHandles().byPage({ maxPageSize: 20 })) {
  console.log(`Page ${i++}:`);
  for (const handle of response.handleList || []) {
    console.log(`\thandle: ${handle.handleId}`);
  }
}

Voorbeeld van het gebruik van paging met een markering:

import { StorageSharedKeyCredential, ShareServiceClient } from "@azure/storage-file-share";

const account = "<account>";
const accountKey = "<accountkey>";

const credential = new StorageSharedKeyCredential(account, accountKey);
const serviceClient = new ShareServiceClient(
  `https://${account}.file.core.windows.net`,
  credential,
);

const shareName = "<share name>";
const directoryName = "<directory name>";
const directoryClient = serviceClient.getShareClient(shareName).getDirectoryClient(directoryName);

let iterator = directoryClient.listHandles().byPage({ maxPageSize: 2 });
let response = (await iterator.next()).value;

for await (const handle of response.handleList || []) {
  console.log(`\thandle: ${handle.handleId}`);
}

// Gets next marker
let marker = response.continuationToken;

// Passing next marker as continuationToken
iterator = directoryClient.listHandles().byPage({ continuationToken: marker, maxPageSize: 10 });
response = (await iterator.next()).value;

for await (const handle of response.handleList || []) {
  console.log(`\thandle: ${handle.handleId}`);
}
rename(string, DirectoryRenameOptions)

Hiermee wijzigt u de naam van een map. Deze API biedt alleen ondersteuning voor het wijzigen van de naam van een map in dezelfde share.

setMetadata(Metadata, DirectorySetMetadataOptions)

Hiermee werkt u door de gebruiker gedefinieerde metagegevens voor de opgegeven map bij.

Zie https://learn.microsoft.com/rest/api/storageservices/set-directory-metadata

setProperties(DirectoryProperties)

Hiermee stelt u eigenschappen in de map in.

Zie https://learn.microsoft.com/rest/api/storageservices/set-directory-properties

Constructordetails

ShareDirectoryClient(string, Credential | TokenCredential, ShareClientOptions)

Hiermee maakt u een exemplaar van DirectoryClient.

new ShareDirectoryClient(url: string, credential?: Credential | TokenCredential, options?: ShareClientOptions)

Parameters

url

string

Een URL-tekenreeks die verwijst naar de Azure Storage-bestandsmap, zoals 'https://myaccount.file.core.windows.net/myshare/mydirectory". U kunt een SAS toevoegen als u AnonymousCredential gebruikt, zoals 'https://myaccount.file.core.windows.net/myshare/mydirectory?sasString". Deze methode accepteert een gecodeerde URL of niet-gecodeerde URL die verwijst naar een map. Gecodeerde URL-tekenreeks wordt NIET tweemaal escaped, alleen speciale tekens in HET URL-pad worden escaped. Als een mapnaam echter %bevat, moet de mapnaam in de URL worden gecodeerd. Zoals een map met de naam 'mydir%', moet de URL zijn 'https://myaccount.file.core.windows.net/myshare/mydir%25".

credential

Credential | TokenCredential

Zoals AnonymousCredential of StorageSharedKeyCredential. Als dit niet is opgegeven, wordt AnonymousCredential gebruikt.

options
ShareClientOptions

Optional. Opties voor het configureren van de HTTP-pijplijn.

ShareDirectoryClient(string, Pipeline, ShareClientConfig)

Hiermee maakt u een exemplaar van DirectoryClient.

new ShareDirectoryClient(url: string, pipeline: Pipeline, options?: ShareClientConfig)

Parameters

url

string

Een URL-tekenreeks die verwijst naar de Azure Storage-bestandsmap, zoals 'https://myaccount.file.core.windows.net/myshare/mydirectory". U kunt een SAS toevoegen als u AnonymousCredential gebruikt, zoals 'https://myaccount.file.core.windows.net/myshare/mydirectory?sasString". Deze methode accepteert een gecodeerde URL of niet-gecodeerde URL die verwijst naar een map. Gecodeerde URL-tekenreeks wordt NIET tweemaal escaped, alleen speciale tekens in HET URL-pad worden escaped. Als een mapnaam echter %bevat, moet de mapnaam in de URL worden gecodeerd. Zoals een map met de naam 'mydir%', moet de URL zijn 'https://myaccount.file.core.windows.net/myshare/mydir%25".

pipeline
Pipeline

Roep newPipeline() aan om een standaardpijplijn te maken of geef een aangepaste pijplijn op.

Eigenschapdetails

name

De naam van de map

string name

Waarde van eigenschap

string

path

Het volledige pad van de map

string path

Waarde van eigenschap

string

shareName

De naam van de share die overeenkomt met deze directoryclient

string shareName

Waarde van eigenschap

string

Details van overgenomen eigenschap

accountName

accountName: string

Waarde van eigenschap

string

overgenomen van StorageClient.accountName

url

URL-tekenreekswaarde.

url: string

Waarde van eigenschap

string

overgenomen van StorageClient.url

Methodedetails

create(DirectoryCreateOptions)

Hiermee maakt u een nieuwe map onder de opgegeven share of bovenliggende map.

Zie https://learn.microsoft.com/rest/api/storageservices/create-directory

function create(options?: DirectoryCreateOptions): Promise<DirectoryCreateResponse>

Parameters

options
DirectoryCreateOptions

Opties voor het maken van mappen.

Retouren

Antwoordgegevens voor de mapbewerking.

createFile(string, number, FileCreateOptions)

Hiermee maakt u een nieuw bestand of vervangt u een bestand onder deze map. Houd er rekening mee dat het bestand alleen wordt geïnitialiseerd zonder inhoud.

Zie https://learn.microsoft.com/rest/api/storageservices/create-file

function createFile(fileName: string, size: number, options?: FileCreateOptions): Promise<{ fileClient: ShareFileClient, fileCreateResponse: FileCreateResponse }>

Parameters

fileName

string

size

number

Hiermee geeft u de maximale grootte in bytes voor het bestand, maximaal 4 TB.

options
FileCreateOptions

Opties voor het maken van bestanden.

Retouren

Promise<{ fileClient: ShareFileClient, fileCreateResponse: FileCreateResponse }>

Antwoordgegevens voor het maken van bestanden en de bijbehorende bestandsclient.

createIfNotExists(DirectoryCreateOptions)

Hiermee maakt u een nieuwe map onder de opgegeven share of bovenliggende map als deze nog niet bestaat. Als de map al bestaat, wordt deze niet gewijzigd.

Zie https://learn.microsoft.com/rest/api/storageservices/create-directory

function createIfNotExists(options?: DirectoryCreateOptions): Promise<DirectoryCreateIfNotExistsResponse>

Parameters

Retouren

createSubdirectory(string, DirectoryCreateOptions)

Hiermee maakt u een nieuwe submap onder deze map.

Zie https://learn.microsoft.com/rest/api/storageservices/create-directory

function createSubdirectory(directoryName: string, options?: DirectoryCreateOptions): Promise<{ directoryClient: ShareDirectoryClient, directoryCreateResponse: DirectoryCreateResponse }>

Parameters

directoryName

string

options
DirectoryCreateOptions

Opties voor het maken van mappen.

Retouren

Promise<{ directoryClient: ShareDirectoryClient, directoryCreateResponse: DirectoryCreateResponse }>

Directory maakt antwoordgegevens en het bijbehorende DirectoryClient-exemplaar.

delete(DirectoryDeleteOptions)

Hiermee verwijdert u de opgegeven lege map. Houd er rekening mee dat de map leeg moet zijn voordat deze kan worden verwijderd.

Zie https://learn.microsoft.com/rest/api/storageservices/delete-directory

function delete(options?: DirectoryDeleteOptions): Promise<DirectoryDeleteResponse>

Parameters

options
DirectoryDeleteOptions

Opties voor de bewerking Map verwijderen.

Retouren

Antwoordgegevens voor de bewerking Map verwijderen.

deleteFile(string, FileDeleteOptions)

Hiermee verwijdert u het opgegeven bestand onder deze map uit het opslagaccount. Wanneer een bestand is verwijderd, wordt het onmiddellijk verwijderd uit de index van het opslagaccount en is het niet meer toegankelijk voor clients. De gegevens van het bestand worden later uit de service verwijderd tijdens de garbagecollection.

Bestand verwijderen mislukt met statuscode 409 (Conflict) en foutcode SharingViolation als het bestand is geopend op een SMB-client.

Bestand verwijderen wordt niet ondersteund op een momentopname van een share. Dit is een alleen-lezen kopie van een share. Een poging om deze bewerking uit te voeren op een momentopname van een share mislukt met 400 (InvalidQueryParameterValue)

Zie https://learn.microsoft.com/rest/api/storageservices/delete-file2

function deleteFile(fileName: string, options?: FileDeleteOptions): Promise<FileDeleteResponse>

Parameters

fileName

string

Naam van het te verwijderen bestand

options
FileDeleteOptions

Opties voor de bewerking Bestand verwijderen.

Retouren

Antwoordgegevens voor het verwijderen van bestanden.

deleteIfExists(DirectoryDeleteOptions)

Hiermee verwijdert u de opgegeven lege map als deze bestaat. Houd er rekening mee dat de map leeg moet zijn voordat deze kan worden verwijderd.

Zie https://learn.microsoft.com/rest/api/storageservices/delete-directory

function deleteIfExists(options?: DirectoryDeleteOptions): Promise<DirectoryDeleteIfExistsResponse>

Parameters

Retouren

deleteSubdirectory(string, DirectoryDeleteOptions)

Hiermee verwijdert u de opgegeven lege submap onder deze map. Houd er rekening mee dat de map leeg moet zijn voordat deze kan worden verwijderd.

Zie https://learn.microsoft.com/rest/api/storageservices/delete-directory

function deleteSubdirectory(directoryName: string, options?: DirectoryDeleteOptions): Promise<DirectoryDeleteResponse>

Parameters

directoryName

string

options
DirectoryDeleteOptions

Opties voor de bewerking Map verwijderen.

Retouren

Antwoordgegevens voor adreslijstverwijdering.

exists(DirectoryExistsOptions)

Retourneert waar als de opgegeven map bestaat; anders onwaar.

OPMERKING: gebruik deze functie met zorg omdat een bestaande map kan worden verwijderd door andere clients of toepassingen. Omgekeerd kunnen nieuwe mappen worden toegevoegd door andere clients of toepassingen nadat deze functie is voltooid.

function exists(options?: DirectoryExistsOptions): Promise<boolean>

Parameters

options
DirectoryExistsOptions

opties voor bestaat bewerking.

Retouren

Promise<boolean>

forceCloseAllHandles(DirectoryForceCloseHandlesSegmentOptions)

Sluit alle ingangen voor een map af.

Zie https://learn.microsoft.com/rest/api/storageservices/force-close-handles

function forceCloseAllHandles(options?: DirectoryForceCloseHandlesSegmentOptions): Promise<CloseHandlesInfo>

Parameters

Retouren

Promise<CloseHandlesInfo>

forceCloseHandle(string, DirectoryForceCloseHandlesOptions)

Sluit een specifieke ingang voor een map af.

Zie https://learn.microsoft.com/rest/api/storageservices/force-close-handles

function forceCloseHandle(handleId: string, options?: DirectoryForceCloseHandlesOptions): Promise<DirectoryForceCloseHandlesResponse>

Parameters

handleId

string

Specifieke handle-id, mag geen sterretje *zijn. Gebruik forceCloseHandlesSegment() om alle ingangen te sluiten.

Retouren

getDirectoryClient(string)

Hiermee maakt u een ShareDirectoryClient-object voor een submap.

function getDirectoryClient(subDirectoryName: string): ShareDirectoryClient

Parameters

subDirectoryName

string

Een submapnaam

Retouren

Het ShareDirectoryClient-object voor de opgegeven submapnaam.

Voorbeeldgebruik:

import { StorageSharedKeyCredential, ShareServiceClient } from "@azure/storage-file-share";

const account = "<account>";
const accountKey = "<accountkey>";

const credential = new StorageSharedKeyCredential(account, accountKey);
const serviceClient = new ShareServiceClient(
  `https://${account}.file.core.windows.net`,
  credential,
);

const shareName = "<share name>";
const directoryName = "<directory name>";
const shareClient = serviceClient.getShareClient(shareName);
const directoryClient = shareClient.getDirectoryClient(directoryName);
await directoryClient.create();

getFileClient(string)

Hiermee maakt u een ShareFileClient--object.

function getFileClient(fileName: string): ShareFileClient

Parameters

fileName

string

Een bestandsnaam.

Retouren

Een nieuw ShareFileClient-object voor de opgegeven bestandsnaam.

Voorbeeldgebruik:

import { StorageSharedKeyCredential, ShareServiceClient } from "@azure/storage-file-share";

const account = "<account>";
const accountKey = "<accountkey>";

const credential = new StorageSharedKeyCredential(account, accountKey);
const serviceClient = new ShareServiceClient(
  `https://${account}.file.core.windows.net`,
  credential,
);

const shareName = "<share name>";
const directoryName = "<directory name>";
const directoryClient = serviceClient.getShareClient(shareName).getDirectoryClient(directoryName);

const content = "Hello World!";
const fileName = `newdirectory${+new Date()}`;
const fileClient = directoryClient.getFileClient(fileName);
await fileClient.create(content.length);
console.log(`Create file ${fileName} successfully`);

// Upload file range
await fileClient.uploadRange(content, 0, content.length);
console.log(`Upload file range "${content}" to ${fileName} successfully`);

getProperties(DirectoryGetPropertiesOptions)

Retourneert alle systeemeigenschappen voor de opgegeven map en kan ook worden gebruikt om het bestaan van een map te controleren. De geretourneerde gegevens bevatten niet de bestanden in de map of submappen.

Zie https://learn.microsoft.com/rest/api/storageservices/get-directory-properties

function getProperties(options?: DirectoryGetPropertiesOptions): Promise<DirectoryGetPropertiesResponse>

Parameters

options
DirectoryGetPropertiesOptions

Opties voor de bewerking Mapeigenschappen ophalen.

Retouren

Antwoordgegevens voor de bewerking Directory Get Properties.

listFilesAndDirectories(DirectoryListFilesAndDirectoriesOptions)

Retourneert een asynchrone iterator om alle bestanden en mappen onder het opgegeven account weer te geven.

.byPage() retourneert een asynchrone iterator om de bestanden en mappen in pagina's weer te geven.

Voorbeeld van for await syntaxis:

import { StorageSharedKeyCredential, ShareServiceClient } from "@azure/storage-file-share";

const account = "<account>";
const accountKey = "<accountkey>";

const credential = new StorageSharedKeyCredential(account, accountKey);
const serviceClient = new ShareServiceClient(
  `https://${account}.file.core.windows.net`,
  credential,
);

const shareName = "<share name>";
const directoryName = "<directory name>";
const directoryClient = serviceClient.getShareClient(shareName).getDirectoryClient(directoryName);

let i = 1;
for await (const item of directoryClient.listFilesAndDirectories()) {
  if (item.kind === "directory") {
    console.log(`${i} - directory\t: ${item.name}`);
  } else {
    console.log(`${i} - file\t: ${item.name}`);
  }
  i++;
}

Voorbeeld van iter.next():

import { StorageSharedKeyCredential, ShareServiceClient } from "@azure/storage-file-share";

const account = "<account>";
const accountKey = "<accountkey>";

const credential = new StorageSharedKeyCredential(account, accountKey);
const serviceClient = new ShareServiceClient(
  `https://${account}.file.core.windows.net`,
  credential,
);

const shareName = "<share name>";
const directoryName = "<directory name>";
const directoryClient = serviceClient.getShareClient(shareName).getDirectoryClient(directoryName);

let i = 1;
const iter = directoryClient.listFilesAndDirectories();
let { value, done } = await iter.next();
while (!done) {
  if (value.kind === "directory") {
    console.log(`${i} - directory\t: ${value.name}`);
  } else {
    console.log(`${i} - file\t: ${value.name}`);
  }
  ({ value, done } = await iter.next());
  i++;
}

Voorbeeld van byPage():

import { StorageSharedKeyCredential, ShareServiceClient } from "@azure/storage-file-share";

const account = "<account>";
const accountKey = "<accountkey>";

const credential = new StorageSharedKeyCredential(account, accountKey);
const serviceClient = new ShareServiceClient(
  `https://${account}.file.core.windows.net`,
  credential,
);

const shareName = "<share name>";
const directoryName = "<directory name>";
const directoryClient = serviceClient.getShareClient(shareName).getDirectoryClient(directoryName);

let i = 1;
for await (const response of directoryClient
  .listFilesAndDirectories()
  .byPage({ maxPageSize: 20 })) {
  console.log(`Page ${i++}:`);
  for (const item of response.segment.directoryItems) {
    console.log(`\tdirectory: ${item.name}`);
  }
  for (const item of response.segment.fileItems) {
    console.log(`\tfile: ${item.name}`);
  }
}

Voorbeeld van het gebruik van paging met een markering:

import { StorageSharedKeyCredential, ShareServiceClient } from "@azure/storage-file-share";

const account = "<account>";
const accountKey = "<accountkey>";

const credential = new StorageSharedKeyCredential(account, accountKey);
const serviceClient = new ShareServiceClient(
  `https://${account}.file.core.windows.net`,
  credential,
);

const shareName = "<share name>";
const directoryName = "<directory name>";
const directoryClient = serviceClient.getShareClient(shareName).getDirectoryClient(directoryName);

let iterator = directoryClient.listFilesAndDirectories().byPage({ maxPageSize: 2 });
let response = (await iterator.next()).value;

for await (const item of response.segment.directoryItems) {
  console.log(`\tdirectory: ${item.name}`);
}

for await (const item of response.segment.fileItems) {
  console.log(`\tfile: ${item.name}`);
}

// Gets next marker
let marker = response.continuationToken;

// Passing next marker as continuationToken
iterator = directoryClient
  .listFilesAndDirectories()
  .byPage({ continuationToken: marker, maxPageSize: 10 });
response = (await iterator.next()).value;

for await (const item of response.segment.directoryItems) {
  console.log(`\tdirectory: ${item.name}`);
}

for await (const item of response.segment.fileItems) {
  console.log(`\tfile: ${item.name}`);
}
function listFilesAndDirectories(options?: DirectoryListFilesAndDirectoriesOptions): PagedAsyncIterableIterator<({ kind: "file" } & FileItem) | ({ kind: "directory" } & DirectoryItem), DirectoryListFilesAndDirectoriesSegmentResponse, PageSettings>

Parameters

options
DirectoryListFilesAndDirectoriesOptions

Opties voor het weergeven van bestanden en mappen.

Retouren

Een asyncIterableIterator die paging ondersteunt.

listHandles(DirectoryListHandlesOptions)

Retourneert een asynchrone iterator om alle ingangen weer te geven. onder het opgegeven account.

.byPage() retourneert een asynchrone iterator om de ingangen in pagina's weer te geven.

Voorbeeld van for await syntaxis:

import { StorageSharedKeyCredential, ShareServiceClient } from "@azure/storage-file-share";

const account = "<account>";
const accountKey = "<accountkey>";

const credential = new StorageSharedKeyCredential(account, accountKey);
const serviceClient = new ShareServiceClient(
  `https://${account}.file.core.windows.net`,
  credential,
);

const shareName = "<share name>";
const directoryName = "<directory name>";
const directoryClient = serviceClient.getShareClient(shareName).getDirectoryClient(directoryName);

for await (const handle of directoryClient.listHandles()) {
  console.log(`Handle: ${handle.handleId}`);
}

Voorbeeld van iter.next():

import { StorageSharedKeyCredential, ShareServiceClient } from "@azure/storage-file-share";

const account = "<account>";
const accountKey = "<accountkey>";

const credential = new StorageSharedKeyCredential(account, accountKey);
const serviceClient = new ShareServiceClient(
  `https://${account}.file.core.windows.net`,
  credential,
);

const shareName = "<share name>";
const directoryName = "<directory name>";
const directoryClient = serviceClient.getShareClient(shareName).getDirectoryClient(directoryName);

const handleIter = directoryClient.listHandles();
let { value, done } = await handleIter.next();
while (!done) {
  console.log(`Handle: ${value.handleId}`);
  ({ value, done } = await handleIter.next());
}

Voorbeeld van byPage():

import { StorageSharedKeyCredential, ShareServiceClient } from "@azure/storage-file-share";

const account = "<account>";
const accountKey = "<accountkey>";

const credential = new StorageSharedKeyCredential(account, accountKey);
const serviceClient = new ShareServiceClient(
  `https://${account}.file.core.windows.net`,
  credential,
);

const shareName = "<share name>";
const directoryName = "<directory name>";
const directoryClient = serviceClient.getShareClient(shareName).getDirectoryClient(directoryName);

let i = 1;
for await (const response of directoryClient.listHandles().byPage({ maxPageSize: 20 })) {
  console.log(`Page ${i++}:`);
  for (const handle of response.handleList || []) {
    console.log(`\thandle: ${handle.handleId}`);
  }
}

Voorbeeld van het gebruik van paging met een markering:

import { StorageSharedKeyCredential, ShareServiceClient } from "@azure/storage-file-share";

const account = "<account>";
const accountKey = "<accountkey>";

const credential = new StorageSharedKeyCredential(account, accountKey);
const serviceClient = new ShareServiceClient(
  `https://${account}.file.core.windows.net`,
  credential,
);

const shareName = "<share name>";
const directoryName = "<directory name>";
const directoryClient = serviceClient.getShareClient(shareName).getDirectoryClient(directoryName);

let iterator = directoryClient.listHandles().byPage({ maxPageSize: 2 });
let response = (await iterator.next()).value;

for await (const handle of response.handleList || []) {
  console.log(`\thandle: ${handle.handleId}`);
}

// Gets next marker
let marker = response.continuationToken;

// Passing next marker as continuationToken
iterator = directoryClient.listHandles().byPage({ continuationToken: marker, maxPageSize: 10 });
response = (await iterator.next()).value;

for await (const handle of response.handleList || []) {
  console.log(`\thandle: ${handle.handleId}`);
}
function listHandles(options?: DirectoryListHandlesOptions): PagedAsyncIterableIterator<HandleItem, DirectoryListHandlesResponse, PageSettings>

Parameters

options
DirectoryListHandlesOptions

Opties voor het weergeven van handlesbewerkingen.

Een asyncIterableIterator die paging ondersteunt.

Retouren

rename(string, DirectoryRenameOptions)

Hiermee wijzigt u de naam van een map. Deze API biedt alleen ondersteuning voor het wijzigen van de naam van een map in dezelfde share.

function rename(destinationPath: string, options?: DirectoryRenameOptions): Promise<{ destinationDirectoryClient: ShareDirectoryClient, directoryRenameResponse: DirectoryRenameResponse }>

Parameters

destinationPath

string

Hiermee geeft u het doelpad om de naam te wijzigen in. Het pad wordt gecodeerd om in een URL te plaatsen om de bestemming op te geven.

options
DirectoryRenameOptions

Opties voor de naamgevingsbewerking.

Retouren

Promise<{ destinationDirectoryClient: ShareDirectoryClient, directoryRenameResponse: DirectoryRenameResponse }>

Antwoordgegevens voor de bewerking voor het wijzigen van de naam van het bestand.

Voorbeeldgebruik:

import { StorageSharedKeyCredential, ShareServiceClient } from "@azure/storage-file-share";

const account = "<account>";
const accountKey = "<accountkey>";

const credential = new StorageSharedKeyCredential(account, accountKey);
const serviceClient = new ShareServiceClient(
  `https://${account}.file.core.windows.net`,
  credential,
);

const shareName = "<share name>";
const directoryName = "<directory name>";
const destinationPath = "<destination path>";
const directoryClient = serviceClient.getShareClient(shareName).getDirectoryClient(directoryName);

await directoryClient.rename(destinationPath);

setMetadata(Metadata, DirectorySetMetadataOptions)

Hiermee werkt u door de gebruiker gedefinieerde metagegevens voor de opgegeven map bij.

Zie https://learn.microsoft.com/rest/api/storageservices/set-directory-metadata

function setMetadata(metadata?: Metadata, options?: DirectorySetMetadataOptions): Promise<DirectorySetMetadataResponse>

Parameters

metadata
Metadata

Als er geen metagegevens worden opgegeven, worden alle bestaande mapmetagegevens verwijderd

options
DirectorySetMetadataOptions

Opties voor de bewerking Metagegevens van directory instellen.

Retouren

Antwoordgegevens voor de bewerking Metagegevens van directoryset.

setProperties(DirectoryProperties)

Hiermee stelt u eigenschappen in de map in.

Zie https://learn.microsoft.com/rest/api/storageservices/set-directory-properties

function setProperties(properties?: DirectoryProperties): Promise<DirectorySetPropertiesResponse>

Parameters

properties
DirectoryProperties

Retouren