共用方式為


ShareClient class

ShareClient 代表 Azure 記憶體共用的 URL,可讓您作其目錄和檔案。

Extends

StorageClient

建構函式

ShareClient(string, Credential | TokenCredential, ShareClientOptions)

建立 ShareClient 的實例。

ShareClient(string, Pipeline, ShareClientConfig)

建立 ShareClient 的實例。

ShareClient(string, string, ShareClientOptions)

屬性

name

共用的名稱

rootDirectoryClient

取得這個共用根目錄的目錄用戶端。 請注意,根目錄一律存在且無法刪除。

根目錄的新 ShareDirectoryClient 物件。

繼承的屬性

accountName
url

URL 字串值。

方法

create(ShareCreateOptions)

在指定的帳戶下建立新的共用。 如果具有相同名稱的共享已經存在,則作業會失敗。

請參閱 https://learn.microsoft.com/rest/api/storageservices/create-share

createDirectory(string, DirectoryCreateOptions)

在此共用下建立新的子目錄。

請參閱 https://learn.microsoft.com/rest/api/storageservices/create-directory

createFile(string, number, FileCreateOptions)

建立新的檔案,或取代此共用根目錄下的檔案。 請注意,它只會初始化沒有內容的檔案。

請參閱 https://learn.microsoft.com/rest/api/storageservices/create-file

createIfNotExists(ShareCreateOptions)

在指定的帳戶下建立新的共用。 如果具有相同名稱的共享已經存在,則不會變更。

請參閱 https://learn.microsoft.com/rest/api/storageservices/create-share

createPermission(string | SharePermission, ShareCreatePermissionOptions)

在共用層級建立檔案許可權(安全性描述項)。 建立的安全性描述元可用於共用中的檔案/目錄。

請參閱 https://learn.microsoft.com/rest/api/storageservices/create-permission

createSnapshot(ShareCreateSnapshotOptions)

建立共用的只讀快照集。

delete(ShareDeleteMethodOptions)

標記要刪除的指定共用。 共用及其中包含的任何目錄或檔案稍後會在垃圾收集期間刪除。

請參閱 https://learn.microsoft.com/rest/api/storageservices/delete-share

deleteDirectory(string, DirectoryDeleteOptions)

拿掉這個共用下指定的空白子目錄。 請注意,目錄必須空白,才能刪除目錄。

請參閱 https://learn.microsoft.com/rest/api/storageservices/delete-directory

deleteFile(string, FileDeleteOptions)

從記憶體帳戶移除此共用根目錄下的檔案。 成功刪除檔案時,它會立即從記憶體帳戶的索引中移除,且客戶端無法再存取。 檔案的數據稍後會在垃圾收集期間從服務中移除。

如果檔案在SMB用戶端上開啟,刪除檔案將會失敗,狀態代碼409(衝突)和錯誤碼 SharingViolation

共用快照集不支援刪除檔案,這是共用的唯讀複本。 嘗試在共用快照集上執行這項作業將會失敗,400 (InvalidQueryParameterValue

請參閱 https://learn.microsoft.com/rest/api/storageservices/delete-file2

deleteIfExists(ShareDeleteMethodOptions)

如果指定共用存在,則標記要刪除的共用。 共用及其中包含的任何目錄或檔案稍後會在垃圾收集期間刪除。

請參閱 https://learn.microsoft.com/rest/api/storageservices/delete-share

exists(ShareExistsOptions)

如果此用戶端所代表的 Azrue 共用資源存在,則傳回 true;否則為 false。

注意:請小心使用此函式,因為其他用戶端或應用程式可能會刪除現有的共用。 反之亦然,此函式完成之後,其他用戶端或應用程式可能會新增新的共用。

generateSasStringToSign(ShareGenerateSasUrlOptions)

僅適用於使用共用密鑰認證建構的 ShareClient。

根據傳入的用戶端屬性和參數,產生字串以簽署服務共用存取簽章 (SAS) URI。 SAS 是由客戶端的共用金鑰認證所簽署。

請參閱 https://learn.microsoft.com/rest/api/storageservices/constructing-a-service-sas

generateSasUrl(ShareGenerateSasUrlOptions)

僅適用於使用共用密鑰認證建構的 ShareClient。

根據傳入的用戶端屬性和參數,產生服務共用存取簽章 (SAS) URI。 SAS 是由客戶端的共用金鑰認證所簽署。

請參閱 https://learn.microsoft.com/rest/api/storageservices/constructing-a-service-sas

getAccessPolicy(ShareGetAccessPolicyOptions)

取得指定共享的許可權。 許可權會指出是否可以公開存取共享數據。

警告:剖析開始和到期字串時,JavaScript 日期可能會遺失有效位數。 例如,新的 Date(“2018-12-31T03:44:23.8827891Z”)將會取得 “2018-12-31T03:44:23.882Z”。

請參閱 https://learn.microsoft.com/rest/api/storageservices/get-share-acl

getDirectoryClient(string)

建立 ShareDirectoryClient 物件。

getPermission(string, ShareGetPermissionOptions)

取得指定檔案許可權密鑰的安全性描述元定義語言 (SDDL),指出安全性描述元。

請參閱 https://learn.microsoft.com/rest/api/storageservices/get-permission

getProperties(ShareGetPropertiesOptions)

傳回指定共用的所有使用者定義元數據和系統屬性。

請參閱 https://learn.microsoft.com/rest/api/storageservices/get-share-properties

警告:回應中傳回的 metadata 物件會以小寫表示,即使它們原本包含大寫字元也一樣。 這與使用 listShares 選項 ShareServiceCl ient includeMetadata 方法所傳回的元數據索引鍵不同,此選項會保留其原始大小寫。

getShareLeaseClient(string)

取得管理檔案租用的 ShareLeaseClient

getStatistics(ShareGetStatisticsOptions)

擷取與共用相關的統計數據。

setAccessPolicy(SignedIdentifier[], ShareSetAccessPolicyOptions)

設定指定共享的許可權。 許可權會指出是否可以公開存取共用中的目錄或檔案。

當您設定共用的許可權時,會取代現有的許可權。 如果未提供 shareAcl,則會移除現有的共用 ACL。

當您在共用上建立預存存取原則時,最多可能需要 30 秒才會生效。 在此間隔期間,與預存存取原則相關聯的共用存取簽章將會失敗,狀態代碼為 403(禁止),直到存取原則變成作用中為止。

請參閱 https://learn.microsoft.com/rest/api/storageservices/set-share-acl

setMetadata(Metadata, ShareSetMetadataOptions)

設定指定共用的一或多個使用者定義名稱/值組。

如果未提供任何選項,或選項參數中未定義任何元數據,則會移除共用元數據。

請參閱 https://learn.microsoft.com/rest/api/storageservices/set-share-metadata

setProperties(ShareSetPropertiesOptions)

設定共用的屬性。

setQuota(number, ShareSetQuotaOptions)

設定指定共用的配額。

withSnapshot(string)

建立與來源相同的新 ShareClient 物件,但具有指定的快照集時間戳。 提供 「“ 會移除快照集,並將 URL 傳回至基底共用。

建構函式詳細資料

ShareClient(string, Credential | TokenCredential, ShareClientOptions)

建立 ShareClient 的實例。

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

參數

url

string

指向 Azure 記憶體檔案共用的 URL 字串,例如 「https://myaccount.file.core.windows.net/share"。 如果使用 AnonymousCredential,則可以附加 SAS,例如 “https://myaccount.file.core.windows.net/share?sasString"。

credential

Credential | TokenCredential

例如 AnonymousCredential 或 StorageSharedKeyCredential。 如果未指定,則會使用 AnonymousCredential。

options
ShareClientOptions

Optional. 設定 HTTP 管線的選項。

ShareClient(string, Pipeline, ShareClientConfig)

建立 ShareClient 的實例。

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

參數

url

string

指向 Azure 記憶體檔案共用的 URL 字串,例如 「https://myaccount.file.core.windows.net/share"。 如果使用 AnonymousCredential,則可以附加 SAS,例如 “https://myaccount.file.core.windows.net/share?sasString"。

pipeline
Pipeline

呼叫 newPipeline() 以建立預設管線,或提供自定義管線。

ShareClient(string, string, ShareClientOptions)

new ShareClient(connectionString: string, name: string, options?: ShareClientOptions)

參數

connectionString

string

帳戶連接字串或 Azure 記憶體帳戶的 SAS 連接字串。 [ 注意 - 帳戶連接字串只能在NODE.JS運行時間使用。 ] 帳戶連接字串範例 - DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=accountKey;EndpointSuffix=core.windows.net SAS 連接字串範例 - BlobEndpoint=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

name

string

共用名稱。

options
ShareClientOptions

Optional. 設定 HTTP 管線的選項。

屬性詳細資料

name

共用的名稱

string name

屬性值

string

rootDirectoryClient

取得這個共用根目錄的目錄用戶端。 請注意,根目錄一律存在且無法刪除。

根目錄的新 ShareDirectoryClient 物件。

ShareDirectoryClient rootDirectoryClient

屬性值

繼承的屬性詳細資料

accountName

accountName: string

屬性值

string

繼承自 StorageClient.accountName

url

URL 字串值。

url: string

屬性值

string

繼承自 StorageClient.url

方法詳細資料

create(ShareCreateOptions)

在指定的帳戶下建立新的共用。 如果具有相同名稱的共享已經存在,則作業會失敗。

請參閱 https://learn.microsoft.com/rest/api/storageservices/create-share

function create(options?: ShareCreateOptions): Promise<ShareCreateResponse>

參數

options
ShareCreateOptions

共用建立作業的選項。

傳回

共用建立作業的響應數據。

createDirectory(string, DirectoryCreateOptions)

在此共用下建立新的子目錄。

請參閱 https://learn.microsoft.com/rest/api/storageservices/create-directory

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

參數

directoryName

string

options
DirectoryCreateOptions

目錄建立作業的選項。

傳回

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

目錄建立回應數據和對應的目錄用戶端。

createFile(string, number, FileCreateOptions)

建立新的檔案,或取代此共用根目錄下的檔案。 請注意,它只會初始化沒有內容的檔案。

請參閱 https://learn.microsoft.com/rest/api/storageservices/create-file

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

參數

fileName

string

size

number

指定檔案的大小上限,最多為 4 TB。

options
FileCreateOptions

檔案建立作業的選項。

傳回

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

檔案建立回應數據和對應的檔案用戶端。

createIfNotExists(ShareCreateOptions)

在指定的帳戶下建立新的共用。 如果具有相同名稱的共享已經存在,則不會變更。

請參閱 https://learn.microsoft.com/rest/api/storageservices/create-share

function createIfNotExists(options?: ShareCreateOptions): Promise<ShareCreateIfNotExistsResponse>

參數

傳回

createPermission(string | SharePermission, ShareCreatePermissionOptions)

在共用層級建立檔案許可權(安全性描述項)。 建立的安全性描述元可用於共用中的檔案/目錄。

請參閱 https://learn.microsoft.com/rest/api/storageservices/create-permission

function createPermission(filePermission: string | SharePermission, options?: ShareCreatePermissionOptions): Promise<ShareCreatePermissionResponse>

參數

filePermission

string | SharePermission

SDDL 中所述的檔案許可權

options
ShareCreatePermissionOptions

共用建立許可權作業的選項。

傳回

createSnapshot(ShareCreateSnapshotOptions)

建立共用的只讀快照集。

function createSnapshot(options?: ShareCreateSnapshotOptions): Promise<ShareCreateSnapshotResponse>

參數

options
ShareCreateSnapshotOptions

共用建立快照集作業的選項。

傳回

共用建立快照集作業的響應數據。

delete(ShareDeleteMethodOptions)

標記要刪除的指定共用。 共用及其中包含的任何目錄或檔案稍後會在垃圾收集期間刪除。

請參閱 https://learn.microsoft.com/rest/api/storageservices/delete-share

function delete(options?: ShareDeleteMethodOptions): Promise<ShareDeleteResponse>

參數

options
ShareDeleteMethodOptions

共用刪除作業的選項。

傳回

共用刪除作業的回應數據。

deleteDirectory(string, DirectoryDeleteOptions)

拿掉這個共用下指定的空白子目錄。 請注意,目錄必須空白,才能刪除目錄。

請參閱 https://learn.microsoft.com/rest/api/storageservices/delete-directory

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

參數

directoryName

string

options
DirectoryDeleteOptions

目錄刪除作業的選項。

傳回

目錄刪除回應數據。

deleteFile(string, FileDeleteOptions)

從記憶體帳戶移除此共用根目錄下的檔案。 成功刪除檔案時,它會立即從記憶體帳戶的索引中移除,且客戶端無法再存取。 檔案的數據稍後會在垃圾收集期間從服務中移除。

如果檔案在SMB用戶端上開啟,刪除檔案將會失敗,狀態代碼409(衝突)和錯誤碼 SharingViolation

共用快照集不支援刪除檔案,這是共用的唯讀複本。 嘗試在共用快照集上執行這項作業將會失敗,400 (InvalidQueryParameterValue

請參閱 https://learn.microsoft.com/rest/api/storageservices/delete-file2

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

參數

fileName

string

options
FileDeleteOptions

檔案刪除作業的選項。

傳回

Promise<FileDeleteResponse> File 刪除響應數據。

deleteIfExists(ShareDeleteMethodOptions)

如果指定共用存在,則標記要刪除的共用。 共用及其中包含的任何目錄或檔案稍後會在垃圾收集期間刪除。

請參閱 https://learn.microsoft.com/rest/api/storageservices/delete-share

function deleteIfExists(options?: ShareDeleteMethodOptions): Promise<ShareDeleteIfExistsResponse>

參數

傳回

exists(ShareExistsOptions)

如果此用戶端所代表的 Azrue 共用資源存在,則傳回 true;否則為 false。

注意:請小心使用此函式,因為其他用戶端或應用程式可能會刪除現有的共用。 反之亦然,此函式完成之後,其他用戶端或應用程式可能會新增新的共用。

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

參數

options
ShareExistsOptions

[存在] 作業的選項。

傳回

Promise<boolean>

generateSasStringToSign(ShareGenerateSasUrlOptions)

僅適用於使用共用密鑰認證建構的 ShareClient。

根據傳入的用戶端屬性和參數,產生字串以簽署服務共用存取簽章 (SAS) URI。 SAS 是由客戶端的共用金鑰認證所簽署。

請參閱 https://learn.microsoft.com/rest/api/storageservices/constructing-a-service-sas

function generateSasStringToSign(options: ShareGenerateSasUrlOptions): string

參數

options
ShareGenerateSasUrlOptions

選擇性參數。

傳回

string

由此用戶端所代表資源的 URI 所組成的 SAS URI,後面接著產生的 SAS 令牌。

generateSasUrl(ShareGenerateSasUrlOptions)

僅適用於使用共用密鑰認證建構的 ShareClient。

根據傳入的用戶端屬性和參數,產生服務共用存取簽章 (SAS) URI。 SAS 是由客戶端的共用金鑰認證所簽署。

請參閱 https://learn.microsoft.com/rest/api/storageservices/constructing-a-service-sas

function generateSasUrl(options: ShareGenerateSasUrlOptions): string

參數

options
ShareGenerateSasUrlOptions

選擇性參數。

傳回

string

由此用戶端所代表資源的 URI 所組成的 SAS URI,後面接著產生的 SAS 令牌。

getAccessPolicy(ShareGetAccessPolicyOptions)

取得指定共享的許可權。 許可權會指出是否可以公開存取共享數據。

警告:剖析開始和到期字串時,JavaScript 日期可能會遺失有效位數。 例如,新的 Date(“2018-12-31T03:44:23.8827891Z”)將會取得 “2018-12-31T03:44:23.882Z”。

請參閱 https://learn.microsoft.com/rest/api/storageservices/get-share-acl

function getAccessPolicy(options?: ShareGetAccessPolicyOptions): Promise<ShareGetAccessPolicyResponse>

參數

傳回

共用取得存取原則作業的響應數據。

getDirectoryClient(string)

建立 ShareDirectoryClient 物件。

function getDirectoryClient(directoryName: string): ShareDirectoryClient

參數

directoryName

string

目錄名稱

傳回

指定目錄名稱的 ShareDirectoryClient 物件。

getPermission(string, ShareGetPermissionOptions)

取得指定檔案許可權密鑰的安全性描述元定義語言 (SDDL),指出安全性描述元。

請參閱 https://learn.microsoft.com/rest/api/storageservices/get-permission

function getPermission(filePermissionKey: string, options?: ShareGetPermissionOptions): Promise<ShareGetPermissionResponse>

參數

filePermissionKey

string

表示許可權之安全性描述元的檔案許可權密鑰。

options
ShareGetPermissionOptions

共用建立許可權作業的選項。

傳回

getProperties(ShareGetPropertiesOptions)

傳回指定共用的所有使用者定義元數據和系統屬性。

請參閱 https://learn.microsoft.com/rest/api/storageservices/get-share-properties

警告:回應中傳回的 metadata 物件會以小寫表示,即使它們原本包含大寫字元也一樣。 這與使用 listShares 選項 ShareServiceCl ient includeMetadata 方法所傳回的元數據索引鍵不同,此選項會保留其原始大小寫。

function getProperties(options?: ShareGetPropertiesOptions): Promise<ShareGetPropertiesResponse>

參數

傳回

共用取得屬性作業的響應數據。

getShareLeaseClient(string)

取得管理檔案租用的 ShareLeaseClient

function getShareLeaseClient(proposeLeaseId?: string): ShareLeaseClient

參數

proposeLeaseId

string

初始建議的租用標識碼。

傳回

用於管理檔案租用的新 ShareLeaseClient 物件。

getStatistics(ShareGetStatisticsOptions)

擷取與共用相關的統計數據。

function getStatistics(options?: ShareGetStatisticsOptions): Promise<ShareGetStatisticsResponse>

參數

傳回

Share Get Statistics 作業的響應數據。

setAccessPolicy(SignedIdentifier[], ShareSetAccessPolicyOptions)

設定指定共享的許可權。 許可權會指出是否可以公開存取共用中的目錄或檔案。

當您設定共用的許可權時,會取代現有的許可權。 如果未提供 shareAcl,則會移除現有的共用 ACL。

當您在共用上建立預存存取原則時,最多可能需要 30 秒才會生效。 在此間隔期間,與預存存取原則相關聯的共用存取簽章將會失敗,狀態代碼為 403(禁止),直到存取原則變成作用中為止。

請參閱 https://learn.microsoft.com/rest/api/storageservices/set-share-acl

function setAccessPolicy(shareAcl?: SignedIdentifier[], options?: ShareSetAccessPolicyOptions): Promise<ShareSetAccessPolicyResponse>

參數

shareAcl

SignedIdentifier[]

已簽署標識碼的陣列,每個標識碼都有唯一標識碼和存取原則的詳細數據。

傳回

共用集存取原則作業的響應數據。

setMetadata(Metadata, ShareSetMetadataOptions)

設定指定共用的一或多個使用者定義名稱/值組。

如果未提供任何選項,或選項參數中未定義任何元數據,則會移除共用元數據。

請參閱 https://learn.microsoft.com/rest/api/storageservices/set-share-metadata

function setMetadata(metadata?: Metadata, options?: ShareSetMetadataOptions): Promise<ShareSetMetadataResponse>

參數

metadata
Metadata

如果未提供任何元數據,則會移除所有現有的目錄元數據。

傳回

共用集元數據作業的響應數據。

setProperties(ShareSetPropertiesOptions)

設定共用的屬性。

function setProperties(options?: ShareSetPropertiesOptions): Promise<ShareSetPropertiesResponse>

參數

傳回

共用集屬性作業的響應數據。

setQuota(number, ShareSetQuotaOptions)

警告

此 API 現已淘汰。

Use setProperties instead.

設定指定共用的配額。

function setQuota(quotaInGB: number, options?: ShareSetQuotaOptions): Promise<ShareSetQuotaResponse>

參數

quotaInGB

number

指定以 GB 為單位的共用大小上限

傳回

共用取得配額作業的響應數據。

withSnapshot(string)

建立與來源相同的新 ShareClient 物件,但具有指定的快照集時間戳。 提供 「“ 會移除快照集,並將 URL 傳回至基底共用。

function withSnapshot(snapshot: string): ShareClient

參數

snapshot

string

快照集時間戳。

傳回

與來源相同的新 ShareClient 物件,但具有指定的快照集時間戳