Megosztás a következőn keresztül:


ShareDirectoryClient class

A ShareDirectoryClient az Azure Storage-címtár URL-címét jelöli, amely lehetővé teszi a fájlok és könyvtárak manipulálását.

Extends

StorageClient

Konstruktorok

ShareDirectoryClient(string, Credential | TokenCredential, ShareClientOptions)

Létrehozza a DirectoryClient egy példányát.

ShareDirectoryClient(string, Pipeline, ShareClientConfig)

Létrehozza a DirectoryClient egy példányát.

Tulajdonságok

name

A könyvtár neve

path

A könyvtár teljes elérési útja

shareName

A címtárügyfélnek megfelelő megosztás neve

Örökölt tulajdonságok

accountName
url

URL-sztring értéke.

Metódusok

create(DirectoryCreateOptions)

Létrehoz egy új könyvtárat a megadott megosztási vagy szülőkönyvtár alatt.

Lásd: https://learn.microsoft.com/rest/api/storageservices/create-directory

createFile(string, number, FileCreateOptions)

Létrehoz egy új fájlt, vagy lecserél egy fájlt ebben a könyvtárban. Vegye figyelembe, hogy csak tartalom nélkül inicializálja a fájlt.

Lásd: https://learn.microsoft.com/rest/api/storageservices/create-file

createIfNotExists(DirectoryCreateOptions)

Új könyvtárat hoz létre a megadott megosztás vagy szülőkönyvtár alatt, ha még nem létezik. Ha a könyvtár már létezik, az nem módosul.

Lásd: https://learn.microsoft.com/rest/api/storageservices/create-directory

createSubdirectory(string, DirectoryCreateOptions)

Új alkönyvtárat hoz létre a könyvtár alatt.

Lásd: https://learn.microsoft.com/rest/api/storageservices/create-directory

delete(DirectoryDeleteOptions)

Eltávolítja a megadott üres könyvtárat. Vegye figyelembe, hogy a címtárnak üresnek kell lennie ahhoz, hogy törölhető legyen.

Lásd: https://learn.microsoft.com/rest/api/storageservices/delete-directory

deleteFile(string, FileDeleteOptions)

Eltávolítja a könyvtár alatt megadott fájlt a tárfiókból. Ha egy fájl sikeresen törölve van, a rendszer azonnal eltávolítja a tárfiók indexéből, és többé nem érhető el az ügyfelek számára. A fájl adatai később törlődnek a szolgáltatásból a szemétgyűjtés során.

A fájl törlése sikertelen lesz a 409-ben (ütközés) és a SharingViolation hibakóddal, ha a fájl SMB-ügyfélen van megnyitva.

A fájl törlése nem támogatott megosztási pillanatképek esetén, amely egy megosztás írásvédett másolata. A megosztási pillanatképen végrehajtott művelet végrehajtása 400-zal meghiúsul (InvalidQueryParameterValue)

Lásd: https://learn.microsoft.com/rest/api/storageservices/delete-file2

deleteIfExists(DirectoryDeleteOptions)

Eltávolítja a megadott üres könyvtárat, ha létezik. Vegye figyelembe, hogy a címtárnak üresnek kell lennie ahhoz, hogy törölhető legyen.

Lásd: https://learn.microsoft.com/rest/api/storageservices/delete-directory

deleteSubdirectory(string, DirectoryDeleteOptions)

Eltávolítja a könyvtár alatt megadott üres alkönyvtárat. Vegye figyelembe, hogy a címtárnak üresnek kell lennie ahhoz, hogy törölhető legyen.

Lásd: https://learn.microsoft.com/rest/api/storageservices/delete-directory

exists(DirectoryExistsOptions)

Igaz értéket ad vissza, ha a megadott könyvtár létezik; máskülönben hamis.

MEGJEGYZÉS: Ezt a függvényt körültekintően használja, mivel előfordulhat, hogy egy meglévő könyvtárat más ügyfelek vagy alkalmazások törölnek. Fordítva, a függvény befejezése után más ügyfelek vagy alkalmazások új könyvtárakat adhatnak hozzá.

forceCloseAllHandles(DirectoryForceCloseHandlesSegmentOptions)

Zárja be a könyvtár összes fogópontját.

Lásd: https://learn.microsoft.com/rest/api/storageservices/force-close-handles

forceCloseHandle(string, DirectoryForceCloseHandlesOptions)

Kényszerítse be egy adott fogópont bezárását egy könyvtárhoz.

Lásd: https://learn.microsoft.com/rest/api/storageservices/force-close-handles

getDirectoryClient(string)

Létrehoz egy ShareDirectoryClient objektumot egy alkönyvtárhoz.

getFileClient(string)

Létrehoz egy ShareFileClient objektumot.

getProperties(DirectoryGetPropertiesOptions)

A megadott könyvtár összes rendszertulajdonságát visszaadja, és a címtár meglétének ellenőrzésére is használható. A visszaadott adatok nem tartalmazzák a könyvtárban vagy alkönyvtárakban lévő fájlokat.

Lásd: https://learn.microsoft.com/rest/api/storageservices/get-directory-properties

listFilesAndDirectories(DirectoryListFilesAndDirectoriesOptions)

Egy aszinkron iterátort ad vissza, amely felsorolja a megadott fiókban lévő összes fájlt és könyvtárat.

A .byPage() aszinkron iterátort ad vissza a lapok fájljainak és könyvtárainak listázásához.

Példa for await szintaxis használatára:

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++;
}

Példa a 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++;
}

Példa a 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}`);
  }
}

Példa jelölővel ellátott lapozásra:

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)

Egy aszinkron iterátort ad vissza az összes fogópont listázásához. a megadott fiók alatt.

A .byPage() egy aszinkron iterátort ad vissza a lapok fogópontjainak listázásához.

Példa for await szintaxis használatára:

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}`);
}

Példa a 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());
}

Példa a 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}`);
  }
}

Példa jelölővel ellátott lapozásra:

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)

Átnevez egy könyvtárat. Ez az API csak egy címtár átnevezését támogatja ugyanabban a megosztásban.

setMetadata(Metadata, DirectorySetMetadataOptions)

Frissíti a felhasználó által megadott metaadatokat a megadott könyvtárhoz.

Lásd: https://learn.microsoft.com/rest/api/storageservices/set-directory-metadata

setProperties(DirectoryProperties)

Beállítja a címtár tulajdonságait.

Lásd: https://learn.microsoft.com/rest/api/storageservices/set-directory-properties

Konstruktor adatai

ShareDirectoryClient(string, Credential | TokenCredential, ShareClientOptions)

Létrehozza a DirectoryClient egy példányát.

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

Paraméterek

url

string

Az Azure Storage-fájlkönyvtárra mutató URL-sztring, például "https://myaccount.file.core.windows.net/myshare/mydirectory". Az SAS hozzáfűzhető, ha AnonymousCredentialt használ, például "https://myaccount.file.core.windows.net/myshare/mydirectory?sasString". Ez a metódus egy kódolt VAGY nem kódolt URL-címet fogad el, amely egy könyvtárra mutat. A kódolt URL-sztring nem lesz kétszer feloldva, csak az URL-elérési út speciális karakterei lesznek feloldva. Ha azonban egy címtárnév %tartalmaz, a címtár nevét az URL-címben kell kódolni. Például egy "mydir%" nevű könyvtárban az URL-címnek "https://myaccount.file.core.windows.net/myshare/mydir%25".

credential

Credential | TokenCredential

Ilyen például a AnonymousCredential vagy a StorageSharedKeyCredential. Ha nincs megadva, az AnonymousCredential lesz használva.

options
ShareClientOptions

Optional. A HTTP-folyamat konfigurálására vonatkozó beállítások.

ShareDirectoryClient(string, Pipeline, ShareClientConfig)

Létrehozza a DirectoryClient egy példányát.

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

Paraméterek

url

string

Az Azure Storage-fájlkönyvtárra mutató URL-sztring, például "https://myaccount.file.core.windows.net/myshare/mydirectory". Az SAS hozzáfűzhető, ha AnonymousCredentialt használ, például "https://myaccount.file.core.windows.net/myshare/mydirectory?sasString". Ez a metódus egy kódolt VAGY nem kódolt URL-címet fogad el, amely egy könyvtárra mutat. A kódolt URL-sztring nem lesz kétszer feloldva, csak az URL-elérési út speciális karakterei lesznek feloldva. Ha azonban egy címtárnév %tartalmaz, a címtár nevét az URL-címben kell kódolni. Például egy "mydir%" nevű könyvtárban az URL-címnek "https://myaccount.file.core.windows.net/myshare/mydir%25".

pipeline
Pipeline

A newPipeline() hívása egy alapértelmezett folyamat létrehozásához vagy egy testreszabott folyamat megadásához.

Tulajdonság adatai

name

A könyvtár neve

string name

Tulajdonság értéke

string

path

A könyvtár teljes elérési útja

string path

Tulajdonság értéke

string

shareName

A címtárügyfélnek megfelelő megosztás neve

string shareName

Tulajdonság értéke

string

Örökölt tulajdonság részletei

accountName

accountName: string

Tulajdonság értéke

string

örökölt StorageClient.accountName

url

URL-sztring értéke.

url: string

Tulajdonság értéke

string

örökölt StorageClient.url-címről

Metódus adatai

create(DirectoryCreateOptions)

Létrehoz egy új könyvtárat a megadott megosztási vagy szülőkönyvtár alatt.

Lásd: https://learn.microsoft.com/rest/api/storageservices/create-directory

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

Paraméterek

options
DirectoryCreateOptions

A címtár-létrehozási művelet beállításai.

Válaszok

Válaszadatok a címtárművelethez.

createFile(string, number, FileCreateOptions)

Létrehoz egy új fájlt, vagy lecserél egy fájlt ebben a könyvtárban. Vegye figyelembe, hogy csak tartalom nélkül inicializálja a fájlt.

Lásd: https://learn.microsoft.com/rest/api/storageservices/create-file

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

Paraméterek

fileName

string

size

number

A fájl maximális méretét adja meg bájtban, legfeljebb 4 TB-ig.

options
FileCreateOptions

A Fájl létrehozása művelet beállításai.

Válaszok

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

Fájllétrehozási válaszadatok és a megfelelő fájlügyfél.

createIfNotExists(DirectoryCreateOptions)

Új könyvtárat hoz létre a megadott megosztás vagy szülőkönyvtár alatt, ha még nem létezik. Ha a könyvtár már létezik, az nem módosul.

Lásd: https://learn.microsoft.com/rest/api/storageservices/create-directory

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

Paraméterek

Válaszok

createSubdirectory(string, DirectoryCreateOptions)

Új alkönyvtárat hoz létre a könyvtár alatt.

Lásd: https://learn.microsoft.com/rest/api/storageservices/create-directory

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

Paraméterek

directoryName

string

options
DirectoryCreateOptions

A címtár-létrehozási művelet beállításai.

Válaszok

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

A címtár válaszadatokat és a megfelelő DirectoryClient-példányt hoz létre.

delete(DirectoryDeleteOptions)

Eltávolítja a megadott üres könyvtárat. Vegye figyelembe, hogy a címtárnak üresnek kell lennie ahhoz, hogy törölhető legyen.

Lásd: https://learn.microsoft.com/rest/api/storageservices/delete-directory

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

Paraméterek

options
DirectoryDeleteOptions

A címtártörlési művelet beállításai.

Válaszok

Válaszadatok a Címtár törlése művelethez.

deleteFile(string, FileDeleteOptions)

Eltávolítja a könyvtár alatt megadott fájlt a tárfiókból. Ha egy fájl sikeresen törölve van, a rendszer azonnal eltávolítja a tárfiók indexéből, és többé nem érhető el az ügyfelek számára. A fájl adatai később törlődnek a szolgáltatásból a szemétgyűjtés során.

A fájl törlése sikertelen lesz a 409-ben (ütközés) és a SharingViolation hibakóddal, ha a fájl SMB-ügyfélen van megnyitva.

A fájl törlése nem támogatott megosztási pillanatképek esetén, amely egy megosztás írásvédett másolata. A megosztási pillanatképen végrehajtott művelet végrehajtása 400-zal meghiúsul (InvalidQueryParameterValue)

Lásd: https://learn.microsoft.com/rest/api/storageservices/delete-file2

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

Paraméterek

fileName

string

A törölni kívánt fájl neve

options
FileDeleteOptions

Fájltörlési művelet beállításai.

Válaszok

Fájltörlési válaszadatok.

deleteIfExists(DirectoryDeleteOptions)

Eltávolítja a megadott üres könyvtárat, ha létezik. Vegye figyelembe, hogy a címtárnak üresnek kell lennie ahhoz, hogy törölhető legyen.

Lásd: https://learn.microsoft.com/rest/api/storageservices/delete-directory

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

Paraméterek

Válaszok

deleteSubdirectory(string, DirectoryDeleteOptions)

Eltávolítja a könyvtár alatt megadott üres alkönyvtárat. Vegye figyelembe, hogy a címtárnak üresnek kell lennie ahhoz, hogy törölhető legyen.

Lásd: https://learn.microsoft.com/rest/api/storageservices/delete-directory

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

Paraméterek

directoryName

string

options
DirectoryDeleteOptions

A címtártörlési művelet beállításai.

Válaszok

Címtártörlési válaszadatok.

exists(DirectoryExistsOptions)

Igaz értéket ad vissza, ha a megadott könyvtár létezik; máskülönben hamis.

MEGJEGYZÉS: Ezt a függvényt körültekintően használja, mivel előfordulhat, hogy egy meglévő könyvtárat más ügyfelek vagy alkalmazások törölnek. Fordítva, a függvény befejezése után más ügyfelek vagy alkalmazások új könyvtárakat adhatnak hozzá.

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

Paraméterek

options
DirectoryExistsOptions

beállítási lehetőségeket a Exists művelethez.

Válaszok

Promise<boolean>

forceCloseAllHandles(DirectoryForceCloseHandlesSegmentOptions)

Zárja be a könyvtár összes fogópontját.

Lásd: https://learn.microsoft.com/rest/api/storageservices/force-close-handles

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

Paraméterek

Válaszok

Promise<CloseHandlesInfo>

forceCloseHandle(string, DirectoryForceCloseHandlesOptions)

Kényszerítse be egy adott fogópont bezárását egy könyvtárhoz.

Lásd: https://learn.microsoft.com/rest/api/storageservices/force-close-handles

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

Paraméterek

handleId

string

Adott leíróazonosító nem lehet "*" csillag. A forceCloseHandlesSegment() használatával zárja be az összes fogópontot.

Válaszok

getDirectoryClient(string)

Létrehoz egy ShareDirectoryClient objektumot egy alkönyvtárhoz.

function getDirectoryClient(subDirectoryName: string): ShareDirectoryClient

Paraméterek

subDirectoryName

string

Alkönyvtár neve

Válaszok

A megadott alkönyvtárnév ShareDirectoryClient objektuma.

Példahasználat:

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)

Létrehoz egy ShareFileClient objektumot.

function getFileClient(fileName: string): ShareFileClient

Paraméterek

fileName

string

Fájlnév.

Válaszok

Egy új ShareFileClient-objektum a megadott fájlnévhez.

Példahasználat:

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)

A megadott könyvtár összes rendszertulajdonságát visszaadja, és a címtár meglétének ellenőrzésére is használható. A visszaadott adatok nem tartalmazzák a könyvtárban vagy alkönyvtárakban lévő fájlokat.

Lásd: https://learn.microsoft.com/rest/api/storageservices/get-directory-properties

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

Paraméterek

options
DirectoryGetPropertiesOptions

A Címtár tulajdonságainak lekérése művelet beállításai.

Válaszok

Válaszadatok a Címtár tulajdonságainak lekérése művelethez.

listFilesAndDirectories(DirectoryListFilesAndDirectoriesOptions)

Egy aszinkron iterátort ad vissza, amely felsorolja a megadott fiókban lévő összes fájlt és könyvtárat.

A .byPage() aszinkron iterátort ad vissza a lapok fájljainak és könyvtárainak listázásához.

Példa for await szintaxis használatára:

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++;
}

Példa a 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++;
}

Példa a 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}`);
  }
}

Példa jelölővel ellátott lapozásra:

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>

Paraméterek

options
DirectoryListFilesAndDirectoriesOptions

Fájlok és könyvtárak műveletet listázó lehetőségek.

Válaszok

Lapozást támogató asyncIterableIterator.

listHandles(DirectoryListHandlesOptions)

Egy aszinkron iterátort ad vissza az összes fogópont listázásához. a megadott fiók alatt.

A .byPage() egy aszinkron iterátort ad vissza a lapok fogópontjainak listázásához.

Példa for await szintaxis használatára:

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}`);
}

Példa a 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());
}

Példa a 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}`);
  }
}

Példa jelölővel ellátott lapozásra:

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>

Paraméterek

options
DirectoryListHandlesOptions

A kezelőművelet listabeállításai.

Lapozást támogató asyncIterableIterator.

Válaszok

rename(string, DirectoryRenameOptions)

Átnevez egy könyvtárat. Ez az API csak egy címtár átnevezését támogatja ugyanabban a megosztásban.

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

Paraméterek

destinationPath

string

Megadja az átnevezendő cél elérési útját. Az elérési út kódolva lesz egy URL-címre a cél megadásához.

options
DirectoryRenameOptions

Az átnevezési művelet beállításai.

Válaszok

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

Válaszadatok a fájl átnevezési műveletéhez.

Példahasználat:

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)

Frissíti a felhasználó által megadott metaadatokat a megadott könyvtárhoz.

Lásd: https://learn.microsoft.com/rest/api/storageservices/set-directory-metadata

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

Paraméterek

metadata
Metadata

Ha nincs megadva metaadat, az összes meglévő címtár-metaadat el lesz távolítva

options
DirectorySetMetadataOptions

A metaadatok címtárbeállítási műveletének beállításai.

Válaszok

Válaszadatok a címtárkészlet metaadatainak műveletéhez.

setProperties(DirectoryProperties)

Beállítja a címtár tulajdonságait.

Lásd: https://learn.microsoft.com/rest/api/storageservices/set-directory-properties

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

Paraméterek

properties
DirectoryProperties

Válaszok