Aracılığıyla paylaş


ShareDirectoryClient class

ShareDirectoryClient, Azure Depolama dizininin bir URL'sini temsil eder ve bu url'nin dosyalarını ve dizinlerini işlemenizi sağlar.

Extends

StorageClient

Oluşturucular

ShareDirectoryClient(string, Credential | TokenCredential, ShareClientOptions)

DirectoryClient'ın bir örneğini oluşturur.

ShareDirectoryClient(string, Pipeline, ShareClientConfig)

DirectoryClient'ın bir örneğini oluşturur.

Özellikler

name

Dizinin adı

path

Dizinin tam yolu

shareName

Bu dizin istemcisine karşılık gelen paylaşım adı

Devralınan Özellikler

accountName
url

URL dizesi değeri.

Yöntemler

create(DirectoryCreateOptions)

Belirtilen paylaşım veya üst dizin altında yeni bir dizin oluşturur.

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

createFile(string, number, FileCreateOptions)

Yeni bir dosya oluşturur veya bu dizin altındaki bir dosyanın yerini alır. Yalnızca içeriği olmayan dosyayı başlatdığını unutmayın.

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

createIfNotExists(DirectoryCreateOptions)

Belirtilen paylaşım veya üst dizin henüz yoksa altında yeni bir dizin oluşturur. Dizin zaten varsa, değiştirilmez.

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

createSubdirectory(string, DirectoryCreateOptions)

Bu dizin altında yeni bir alt dizin oluşturur.

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

delete(DirectoryDeleteOptions)

Belirtilen boş dizini kaldırır. Silinebilmesi için önce dizinin boş olması gerektiğini unutmayın.

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

deleteFile(string, FileDeleteOptions)

Bu dizin altında belirtilen dosyayı depolama hesabından kaldırır. Bir dosya başarıyla silindiğinde, depolama hesabının dizininden hemen kaldırılır ve artık istemciler tarafından erişilemez. Dosyanın verileri daha sonra çöp toplama sırasında hizmetten kaldırılır.

Silme Dosyası, SMB istemcisinde açıksa 409 (Çakışma) durum kodu ve SharingViolation hata koduyla başarısız olur.

Dosya Sil, paylaşımın salt okunur bir kopyası olan paylaşım anlık görüntüsünde desteklenmez. Paylaşım anlık görüntüsünde bu işlemi gerçekleştirme girişimi 400 (InvalidQueryParameterValue) ile başarısız olur

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

deleteIfExists(DirectoryDeleteOptions)

Varsa belirtilen boş dizini kaldırır. Silinebilmesi için önce dizinin boş olması gerektiğini unutmayın.

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

deleteSubdirectory(string, DirectoryDeleteOptions)

Bu dizinin altındaki belirtilen boş alt dizini kaldırır. Silinebilmesi için önce dizinin boş olması gerektiğini unutmayın.

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

exists(DirectoryExistsOptions)

Belirtilen dizin varsa true döndürür; false olarak ayarlayın.

NOT: Mevcut bir dizin diğer istemciler veya uygulamalar tarafından silinebileceğinden bu işlevi dikkatli kullanın. Bu işlev tamamlandıktan sonra diğer istemciler veya uygulamalar tarafından yeni dizinler eklenebilir.

forceCloseAllHandles(DirectoryForceCloseHandlesSegmentOptions)

Dizin için tüm tanıtıcıları kapatmaya zorlar.

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

forceCloseHandle(string, DirectoryForceCloseHandlesOptions)

Dizin için belirli bir tanıtıcıyı kapatmaya zorlama.

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

getDirectoryClient(string)

Bir alt dizin için ShareDirectoryClient nesnesi oluşturur.

getFileClient(string)

bir ShareFileClient nesnesi oluşturur.

getProperties(DirectoryGetPropertiesOptions)

Belirtilen dizin için tüm sistem özelliklerini döndürür ve bir dizinin varlığını denetlemek için de kullanılabilir. Döndürülen veriler dizindeki dosyaları veya alt dizinleri içermez.

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

listFilesAndDirectories(DirectoryListFilesAndDirectoriesOptions)

Belirtilen hesap altındaki tüm dosyaları ve dizinleri listelemek için zaman uyumsuz bir yinelenebilir yineleyici döndürür.

.byPage() sayfalardaki dosyaları ve dizinleri listelemek için zaman uyumsuz bir yinelenebilir yineleyici döndürür.

for await söz dizimi kullanan örnek:

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

iter.next()kullanan örnek:

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

byPage()kullanan örnek:

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

İşaretçi ile disk belleği kullanma örneği:

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)

Tüm tanıtıcıları listelemek için zaman uyumsuz bir yinelenebilir yineleyici döndürür. öğesini seçin.

.byPage() sayfalardaki tanıtıcıları listelemek için zaman uyumsuz bir yinelenebilir yineleyici döndürür.

for await söz dizimi kullanan örnek:

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

iter.next()kullanan örnek:

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

byPage()kullanan örnek:

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

İşaretçi ile disk belleği kullanma örneği:

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)

Dizini yeniden adlandırır. Bu API yalnızca aynı paylaşımdaki bir dizinin yeniden adlandırılabilmesini destekler.

setMetadata(Metadata, DirectorySetMetadataOptions)

Belirtilen dizin için kullanıcı tanımlı meta verileri güncelleştirir.

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

setProperties(DirectoryProperties)

Dizindeki özellikleri ayarlar.

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

Oluşturucu Ayrıntıları

ShareDirectoryClient(string, Credential | TokenCredential, ShareClientOptions)

DirectoryClient'ın bir örneğini oluşturur.

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

Parametreler

url

string

Azure Depolama dosya dizinine işaret eden "https://myaccount.file.core.windows.net/myshare/mydirectory" gibi bir URL dizesi. AnonymousCredential kullanıyorsanız , "https://myaccount.file.core.windows.net/myshare/mydirectory?sasString" gibi bir SAS ekleyebilirsiniz. Bu yöntem, bir dizine işaret eden kodlanmış url'yi veya kodlanmamış URL'yi kabul eder. Kodlanmış URL dizesi iki kez kaçılmaz, YALNıZCA URL yolundaki özel karakterlerden kaçılır. Ancak, dizin adı %içeriyorsa, dizin adı URL'de kodlanmalıdır. "mydir%" adlı bir dizin gibi, URL "https://myaccount.file.core.windows.net/myshare/mydir%25" olmalıdır.

credential

Credential | TokenCredential

AnonymousCredential veya StorageSharedKeyCredential gibi. Belirtilmezse, AnonymousCredential kullanılır.

options
ShareClientOptions

Optional. HTTP işlem hattını yapılandırma seçenekleri.

ShareDirectoryClient(string, Pipeline, ShareClientConfig)

DirectoryClient'ın bir örneğini oluşturur.

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

Parametreler

url

string

Azure Depolama dosya dizinine işaret eden "https://myaccount.file.core.windows.net/myshare/mydirectory" gibi bir URL dizesi. AnonymousCredential kullanıyorsanız , "https://myaccount.file.core.windows.net/myshare/mydirectory?sasString" gibi bir SAS ekleyebilirsiniz. Bu yöntem, bir dizine işaret eden kodlanmış url'yi veya kodlanmamış URL'yi kabul eder. Kodlanmış URL dizesi iki kez kaçılmaz, YALNıZCA URL yolundaki özel karakterlerden kaçılır. Ancak, dizin adı %içeriyorsa, dizin adı URL'de kodlanmalıdır. "mydir%" adlı bir dizin gibi, URL "https://myaccount.file.core.windows.net/myshare/mydir%25" olmalıdır.

pipeline
Pipeline

Varsayılan işlem hattı oluşturmak veya özelleştirilmiş bir işlem hattı sağlamak için newPipeline() çağrısında bulunabilirsiniz.

Özellik Ayrıntıları

name

Dizinin adı

string name

Özellik Değeri

string

path

Dizinin tam yolu

string path

Özellik Değeri

string

shareName

Bu dizin istemcisine karşılık gelen paylaşım adı

string shareName

Özellik Değeri

string

Devralınan Özellik Detayları

accountName

accountName: string

Özellik Değeri

string

StorageClient.accountName'den Devralınan

url

URL dizesi değeri.

url: string

Özellik Değeri

string

StorageClient.url'den Devralınan

Yöntem Ayrıntıları

create(DirectoryCreateOptions)

Belirtilen paylaşım veya üst dizin altında yeni bir dizin oluşturur.

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

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

Parametreler

options
DirectoryCreateOptions

Dizin Oluşturma işlemi seçenekleri.

Döndürülenler

Dizin işlemi için yanıt verileri.

createFile(string, number, FileCreateOptions)

Yeni bir dosya oluşturur veya bu dizin altındaki bir dosyanın yerini alır. Yalnızca içeriği olmayan dosyayı başlatdığını unutmayın.

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

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

Parametreler

fileName

string

size

number

Dosya için bayt cinsinden en büyük boyutu (en fazla 4 TB) belirtir.

options
FileCreateOptions

Dosya Oluşturma işlemi seçenekleri.

Döndürülenler

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

Dosya oluşturma yanıt verileri ve buna karşılık gelen dosya istemcisi.

createIfNotExists(DirectoryCreateOptions)

Belirtilen paylaşım veya üst dizin henüz yoksa altında yeni bir dizin oluşturur. Dizin zaten varsa, değiştirilmez.

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

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

Parametreler

Döndürülenler

createSubdirectory(string, DirectoryCreateOptions)

Bu dizin altında yeni bir alt dizin oluşturur.

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

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

Parametreler

directoryName

string

options
DirectoryCreateOptions

Dizin Oluşturma işlemi seçenekleri.

Döndürülenler

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

Dizin oluşturma yanıt verileri ve karşılık gelen DirectoryClient örneği.

delete(DirectoryDeleteOptions)

Belirtilen boş dizini kaldırır. Silinebilmesi için önce dizinin boş olması gerektiğini unutmayın.

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

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

Parametreler

options
DirectoryDeleteOptions

Dizin Silme işlemi seçenekleri.

Döndürülenler

Dizin Silme işlemi için yanıt verileri.

deleteFile(string, FileDeleteOptions)

Bu dizin altında belirtilen dosyayı depolama hesabından kaldırır. Bir dosya başarıyla silindiğinde, depolama hesabının dizininden hemen kaldırılır ve artık istemciler tarafından erişilemez. Dosyanın verileri daha sonra çöp toplama sırasında hizmetten kaldırılır.

Silme Dosyası, SMB istemcisinde açıksa 409 (Çakışma) durum kodu ve SharingViolation hata koduyla başarısız olur.

Dosya Sil, paylaşımın salt okunur bir kopyası olan paylaşım anlık görüntüsünde desteklenmez. Paylaşım anlık görüntüsünde bu işlemi gerçekleştirme girişimi 400 (InvalidQueryParameterValue) ile başarısız olur

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

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

Parametreler

fileName

string

Silinecek dosyanın adı

options
FileDeleteOptions

Dosya Silme işlemi seçenekleri.

Döndürülenler

Dosya silme yanıt verileri.

deleteIfExists(DirectoryDeleteOptions)

Varsa belirtilen boş dizini kaldırır. Silinebilmesi için önce dizinin boş olması gerektiğini unutmayın.

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

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

Parametreler

Döndürülenler

deleteSubdirectory(string, DirectoryDeleteOptions)

Bu dizinin altındaki belirtilen boş alt dizini kaldırır. Silinebilmesi için önce dizinin boş olması gerektiğini unutmayın.

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

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

Parametreler

directoryName

string

options
DirectoryDeleteOptions

Dizin Silme işlemi seçenekleri.

Döndürülenler

Dizin silme yanıt verileri.

exists(DirectoryExistsOptions)

Belirtilen dizin varsa true döndürür; false olarak ayarlayın.

NOT: Mevcut bir dizin diğer istemciler veya uygulamalar tarafından silinebileceğinden bu işlevi dikkatli kullanın. Bu işlev tamamlandıktan sonra diğer istemciler veya uygulamalar tarafından yeni dizinler eklenebilir.

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

Parametreler

options
DirectoryExistsOptions

seçeneklerine tıklayın.

Döndürülenler

Promise<boolean>

forceCloseAllHandles(DirectoryForceCloseHandlesSegmentOptions)

Dizin için tüm tanıtıcıları kapatmaya zorlar.

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

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

Parametreler

Döndürülenler

Promise<CloseHandlesInfo>

forceCloseHandle(string, DirectoryForceCloseHandlesOptions)

Dizin için belirli bir tanıtıcıyı kapatmaya zorlama.

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

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

Parametreler

handleId

string

Belirli tanıtıcı kimliği, yıldız işareti "*" olamaz. Tüm tanıtıcıları kapatmak için forceCloseHandlesSegment() kullanın.

Döndürülenler

getDirectoryClient(string)

Bir alt dizin için ShareDirectoryClient nesnesi oluşturur.

function getDirectoryClient(subDirectoryName: string): ShareDirectoryClient

Parametreler

subDirectoryName

string

Alt dizin adı

Döndürülenler

Verilen alt dizin adı için ShareDirectoryClient nesnesi.

Örnek kullanım:

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)

bir ShareFileClient nesnesi oluşturur.

function getFileClient(fileName: string): ShareFileClient

Parametreler

fileName

string

Dosya adı.

Döndürülenler

Belirtilen dosya adı için yeni bir ShareFileClient nesnesi.

Örnek kullanım:

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)

Belirtilen dizin için tüm sistem özelliklerini döndürür ve bir dizinin varlığını denetlemek için de kullanılabilir. Döndürülen veriler dizindeki dosyaları veya alt dizinleri içermez.

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

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

Parametreler

options
DirectoryGetPropertiesOptions

Dizin Alma Özellikleri işlemi seçenekleri.

Döndürülenler

Dizin Alma Özellikleri işlemi için yanıt verileri.

listFilesAndDirectories(DirectoryListFilesAndDirectoriesOptions)

Belirtilen hesap altındaki tüm dosyaları ve dizinleri listelemek için zaman uyumsuz bir yinelenebilir yineleyici döndürür.

.byPage() sayfalardaki dosyaları ve dizinleri listelemek için zaman uyumsuz bir yinelenebilir yineleyici döndürür.

for await söz dizimi kullanan örnek:

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

iter.next()kullanan örnek:

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

byPage()kullanan örnek:

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

İşaretçi ile disk belleği kullanma örneği:

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>

Parametreler

options
DirectoryListFilesAndDirectoriesOptions

Dosyaları ve dizinleri listeleme işlemi seçenekleri.

Döndürülenler

Disk belleğini destekleyen asyncIterableIterator.

listHandles(DirectoryListHandlesOptions)

Tüm tanıtıcıları listelemek için zaman uyumsuz bir yinelenebilir yineleyici döndürür. öğesini seçin.

.byPage() sayfalardaki tanıtıcıları listelemek için zaman uyumsuz bir yinelenebilir yineleyici döndürür.

for await söz dizimi kullanan örnek:

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

iter.next()kullanan örnek:

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

byPage()kullanan örnek:

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

İşaretçi ile disk belleği kullanma örneği:

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>

Parametreler

options
DirectoryListHandlesOptions

Liste işlemeleri işlemi seçenekleri.

Disk belleğini destekleyen asyncIterableIterator.

Döndürülenler

rename(string, DirectoryRenameOptions)

Dizini yeniden adlandırır. Bu API yalnızca aynı paylaşımdaki bir dizinin yeniden adlandırılabilmesini destekler.

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

Parametreler

destinationPath

string

Yeniden adlandıracak hedef yolu belirtir. Yol, hedefi belirtmek için url'ye yerleştirilecek şekilde kodlanır.

options
DirectoryRenameOptions

Yeniden adlandırma işlemi seçenekleri.

Döndürülenler

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

Dosya yeniden adlandırma işlemi için yanıt verileri.

Örnek kullanım:

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)

Belirtilen dizin için kullanıcı tanımlı meta verileri güncelleştirir.

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

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

Parametreler

metadata
Metadata

Meta veri sağlanmazsa, var olan tüm dizin meta verileri kaldırılır

options
DirectorySetMetadataOptions

Dizin Kümesi Meta Verileri işlemi seçenekleri.

Döndürülenler

Dizin Kümesi Meta Verileri işlemi için yanıt verileri.

setProperties(DirectoryProperties)

Dizindeki özellikleri ayarlar.

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

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

Parametreler

properties
DirectoryProperties

Döndürülenler