Sdílet prostřednictvím


ShareServiceClient class

ShareServiceClient představuje adresu URL služby Azure Storage File, která umožňuje manipulovat se sdílenými složkami.

Extends

StorageClient

Konstruktory

ShareServiceClient(string, Credential | TokenCredential, ShareClientOptions)

Vytvoří instanci ShareServiceClient.

ShareServiceClient(string, Pipeline, ShareClientConfig)

Vytvoří instanci ShareServiceClient.

Zděděné vlastnosti

accountName
url

Hodnota řetězce adresy URL.

Metody

createShare(string, ShareCreateOptions)

Vytvoří sdílenou složku.

deleteShare(string, ShareDeleteMethodOptions)

Odstraní sdílenou složku.

fromConnectionString(string, ShareClientOptions)

Vytvoří instanci ShareServiceClient z připojovacího řetězce.

generateAccountSasUrl(Date, AccountSASPermissions, string, ServiceGenerateAccountSasUrlOptions)

K dispozici pouze pro ShareServiceClient vytvořený s přihlašovacími údaji sdíleného klíče.

Vygeneruje identifikátor URI sdíleného přístupového podpisu účtu na základě vlastností klienta a parametrů předaných. Sas je podepsán přihlašovacími údaji sdíleného klíče klienta.

Viz https://learn.microsoft.com/rest/api/storageservices/create-account-sas

generateSasStringToSign(Date, AccountSASPermissions, string, ServiceGenerateAccountSasUrlOptions)

K dispozici pouze pro ShareServiceClient vytvořený s přihlašovacími údaji sdíleného klíče.

Vygeneruje řetězec pro podepsání identifikátoru URI sdíleného přístupového podpisu (SAS) účtu na základě vlastností klienta a parametrů předaných. Sas je podepsán přihlašovacími údaji sdíleného klíče klienta.

Viz https://learn.microsoft.com/rest/api/storageservices/create-account-sas

getProperties(ServiceGetPropertiesOptions)

Získá vlastnosti souborové služby účtu úložiště, včetně vlastností pro pravidla Analýzy úložiště a CORS (sdílení prostředků mezi zdroji).

Viz https://learn.microsoft.com/rest/api/storageservices/get-file-service-properties

getShareClient(string)

Vytvoří objekt ShareClient.

listShares(ServiceListSharesOptions)

Vrátí asynchronní iterátor pro výpis všech sdílených složek v rámci zadaného účtu.

.byPage() vrátí asynchronní iterátor pro výpis sdílených složek na stránkách.

Příklad použití syntaxe for await:

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,
);

let i = 1;
for await (const share of serviceClient.listShares()) {
  console.log(`Share${i++}: ${share.name}`);
}

Příklad použití 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 shareIter = serviceClient.listShares();
let i = 1;
let { value, done } = await shareIter.next();
while (!done) {
  console.log(`Share ${i++}: ${value.name}`);
  ({ value, done } = await shareIter.next());
}

Příklad použití 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,
);

let i = 1;
for await (const response of serviceClient.listShares().byPage({ maxPageSize: 20 })) {
  console.log(`Page ${i++}:`);
  for (const share of response.shareItems || []) {
    console.log(`\tShare: ${share.name}`);
  }
}

Příklad použití stránkování se značkou:

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,
);

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

for await (const share of response.shareItems || []) {
  console.log(`\tShare: ${share.name}`);
}

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

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

for await (const share of response.shareItems || []) {
  console.log(`\tShare: ${share.name}`);
}
setProperties(FileServiceProperties, ServiceSetPropertiesOptions)

Nastaví vlastnosti koncového bodu souborové služby účtu úložiště, včetně vlastností pro analýzu úložiště, pravidel CORS (sdílení prostředků mezi zdroji) a nastavení obnovitelného odstranění.

Viz https://learn.microsoft.com/rest/api/storageservices/set-file-service-properties

undeleteShare(string, string, ServiceUndeleteShareOptions)

Obnoví dříve odstraněnou sdílenou složku. Toto rozhraní API je funkční pouze v případě, že je povolené obnovitelné odstranění sdílené složky pro účet úložiště přidruženého ke sdílené složce.

Podrobnosti konstruktoru

ShareServiceClient(string, Credential | TokenCredential, ShareClientOptions)

Vytvoří instanci ShareServiceClient.

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

Parametry

url

string

Řetězec adresy URL odkazující na souborovou službu Azure Storage, například "https://myaccount.file.core.windows.net". Sas můžete připojit, pokud používáte AnonymousCredential, například "https://myaccount.file.core.windows.net?sasString".

credential

Credential | TokenCredential

Například AnonymousCredential, StorageSharedKeyCredential nebo TokenCredential, Pokud není zadána, použije se AnonymníCredential.

options
ShareClientOptions

Optional. Možnosti konfigurace kanálu HTTP

ShareServiceClient(string, Pipeline, ShareClientConfig)

Vytvoří instanci ShareServiceClient.

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

Parametry

url

string

Řetězec adresy URL odkazující na souborovou službu Azure Storage, například "https://myaccount.file.core.windows.net". Sas můžete připojit, pokud používáte AnonymousCredential, například "https://myaccount.file.core.windows.net?sasString".

pipeline
Pipeline

Voláním metody newPipeline() vytvořte výchozí kanál nebo zadejte přizpůsobený kanál.

options
ShareClientConfig

Optional. Možnosti konfigurace kanálu HTTP

Podrobnosti zděděných vlastností

accountName

accountName: string

Hodnota vlastnosti

string

zděděno ze StorageClient.accountName

url

Hodnota řetězce adresy URL.

url: string

Hodnota vlastnosti

string

zděděno ze StorageClient.url

Podrobnosti metody

createShare(string, ShareCreateOptions)

Vytvoří sdílenou složku.

function createShare(shareName: string, options?: ShareCreateOptions): Promise<{ shareClient: ShareClient, shareCreateResponse: ShareCreateResponse }>

Parametry

shareName

string

Návraty

Promise<{ shareClient: ShareClient, shareCreateResponse: ShareCreateResponse }>

Odpověď na vytvoření sdílené složky a odpovídajícího klienta sdílené složky.

deleteShare(string, ShareDeleteMethodOptions)

Odstraní sdílenou složku.

function deleteShare(shareName: string, options?: ShareDeleteMethodOptions): Promise<ShareDeleteResponse>

Parametry

shareName

string

Návraty

Odpověď na odstranění sdílené složky a odpovídajícího klienta sdílené složky.

fromConnectionString(string, ShareClientOptions)

Vytvoří instanci ShareServiceClient z připojovacího řetězce.

static function fromConnectionString(connectionString: string, options?: ShareClientOptions): ShareServiceClient

Parametry

connectionString

string

Připojovací řetězec účtu nebo připojovací řetězec SAS účtu úložiště Azure. [ Poznámka: Připojovací řetězec účtu lze použít pouze v NODE.JS modulu runtime. ] Příklad připojovacího řetězce účtu – Příklad připojovacího řetězce SAS DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=accountKey;EndpointSuffix=core.windows.netBlobEndpoint=https://myaccount.blob.core.windows.net/;QueueEndpoint=https://myaccount.queue.core.windows.net/;FileEndpoint=https://myaccount.file.core.windows.net/;TableEndpoint=https://myaccount.table.core.windows.net/;SharedAccessSignature=sasString

options
ShareClientOptions

Možnosti konfigurace kanálu HTTP

Návraty

Nový ShareServiceClient z daného připojovacího řetězce.

generateAccountSasUrl(Date, AccountSASPermissions, string, ServiceGenerateAccountSasUrlOptions)

K dispozici pouze pro ShareServiceClient vytvořený s přihlašovacími údaji sdíleného klíče.

Vygeneruje identifikátor URI sdíleného přístupového podpisu účtu na základě vlastností klienta a parametrů předaných. Sas je podepsán přihlašovacími údaji sdíleného klíče klienta.

Viz https://learn.microsoft.com/rest/api/storageservices/create-account-sas

function generateAccountSasUrl(expiresOn?: Date, permissions?: AccountSASPermissions, resourceTypes?: string, options?: ServiceGenerateAccountSasUrlOptions): string

Parametry

expiresOn

Date

Optional. Čas, kdy se sdílený přístupový podpis stane neplatným. Výchozí hodnota je hodina později, pokud není zadána.

permissions
AccountSASPermissions

Určuje seznamoprávněních

resourceTypes

string

Určuje typy prostředků přidružené ke sdílenému přístupovém podpisu.

options
ServiceGenerateAccountSasUrlOptions

Volitelné parametry.

Návraty

string

Identifikátor URI SAS účtu, který se skládá z identifikátoru URI pro prostředek reprezentovaný tímto klientem, následovaný vygenerovaným tokenem SAS.

generateSasStringToSign(Date, AccountSASPermissions, string, ServiceGenerateAccountSasUrlOptions)

K dispozici pouze pro ShareServiceClient vytvořený s přihlašovacími údaji sdíleného klíče.

Vygeneruje řetězec pro podepsání identifikátoru URI sdíleného přístupového podpisu (SAS) účtu na základě vlastností klienta a parametrů předaných. Sas je podepsán přihlašovacími údaji sdíleného klíče klienta.

Viz https://learn.microsoft.com/rest/api/storageservices/create-account-sas

function generateSasStringToSign(expiresOn?: Date, permissions?: AccountSASPermissions, resourceTypes?: string, options?: ServiceGenerateAccountSasUrlOptions): string

Parametry

expiresOn

Date

Optional. Čas, kdy se sdílený přístupový podpis stane neplatným. Výchozí hodnota je hodina později, pokud není zadána.

permissions
AccountSASPermissions

Určuje seznamoprávněních

resourceTypes

string

Určuje typy prostředků přidružené ke sdílenému přístupovém podpisu.

options
ServiceGenerateAccountSasUrlOptions

Volitelné parametry.

Návraty

string

Identifikátor URI SAS účtu, který se skládá z identifikátoru URI pro prostředek reprezentovaný tímto klientem, následovaný vygenerovaným tokenem SAS.

getProperties(ServiceGetPropertiesOptions)

Získá vlastnosti souborové služby účtu úložiště, včetně vlastností pro pravidla Analýzy úložiště a CORS (sdílení prostředků mezi zdroji).

Viz https://learn.microsoft.com/rest/api/storageservices/get-file-service-properties

function getProperties(options?: ServiceGetPropertiesOptions): Promise<ServiceGetPropertiesResponse>

Parametry

options
ServiceGetPropertiesOptions

Možnosti pro získání operace Vlastnosti

Návraty

Data odpovědi pro operaci Získat vlastnosti.

getShareClient(string)

Vytvoří objekt ShareClient.

function getShareClient(shareName: string): ShareClient

Parametry

shareName

string

Název sdílené složky.

Návraty

Objekt ShareClient pro daný název sdílené složky.

Příklad použití:

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 shareClient = serviceClient.getShareClient(shareName);
await shareClient.create();

listShares(ServiceListSharesOptions)

Vrátí asynchronní iterátor pro výpis všech sdílených složek v rámci zadaného účtu.

.byPage() vrátí asynchronní iterátor pro výpis sdílených složek na stránkách.

Příklad použití syntaxe for await:

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,
);

let i = 1;
for await (const share of serviceClient.listShares()) {
  console.log(`Share${i++}: ${share.name}`);
}

Příklad použití 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 shareIter = serviceClient.listShares();
let i = 1;
let { value, done } = await shareIter.next();
while (!done) {
  console.log(`Share ${i++}: ${value.name}`);
  ({ value, done } = await shareIter.next());
}

Příklad použití 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,
);

let i = 1;
for await (const response of serviceClient.listShares().byPage({ maxPageSize: 20 })) {
  console.log(`Page ${i++}:`);
  for (const share of response.shareItems || []) {
    console.log(`\tShare: ${share.name}`);
  }
}

Příklad použití stránkování se značkou:

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,
);

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

for await (const share of response.shareItems || []) {
  console.log(`\tShare: ${share.name}`);
}

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

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

for await (const share of response.shareItems || []) {
  console.log(`\tShare: ${share.name}`);
}
function listShares(options?: ServiceListSharesOptions): PagedAsyncIterableIterator<ShareItem, ServiceListSharesSegmentResponse, PageSettings>

Parametry

options
ServiceListSharesOptions

Možnosti operace výpisu sdílených složek

AsyncIterableIterator, který podporuje stránkování.

Návraty

setProperties(FileServiceProperties, ServiceSetPropertiesOptions)

Nastaví vlastnosti koncového bodu souborové služby účtu úložiště, včetně vlastností pro analýzu úložiště, pravidel CORS (sdílení prostředků mezi zdroji) a nastavení obnovitelného odstranění.

Viz https://learn.microsoft.com/rest/api/storageservices/set-file-service-properties

function setProperties(properties: FileServiceProperties, options?: ServiceSetPropertiesOptions): Promise<ServiceSetPropertiesResponse>

Parametry

options
ServiceSetPropertiesOptions

Možnosti nastavení operace Vlastnosti

Návraty

Data odpovědi pro operaci Nastavit vlastnosti.

undeleteShare(string, string, ServiceUndeleteShareOptions)

Obnoví dříve odstraněnou sdílenou složku. Toto rozhraní API je funkční pouze v případě, že je povolené obnovitelné odstranění sdílené složky pro účet úložiště přidruženého ke sdílené složce.

function undeleteShare(deletedShareName: string, deletedShareVersion: string, options?: ServiceUndeleteShareOptions): Promise<ShareClient>

Parametry

deletedShareName

string

Název dříve odstraněné sdílené složky.

deletedShareVersion

string

Verze dříve odstraněné sdílené složky.

options
ServiceUndeleteShareOptions

Možnosti sdílení operace zrušení zrušení.

Návraty

Promise<ShareClient>

Obnovená sdílená složka.