@azure/storage-file package
類別
| Aborter |
中止器實例會實作 AbortSignal 介面,可以中止 HTTP 要求。
針對現有的實例 aborter:
|
| AccountSASPermissions |
僅適用於運行時間NODE.JS。 這是協助程序類別,用來建構代表 AccountSAS 授與之許可權的字串。 將值設定為 true 表示任何使用這些許可權的 SAS 都會授與該作業的許可權。 設定所有值之後,應該使用 toString 串行化,並設定為 <xref:IAccountSASSignatureValues> 對象的許可權欄位。 可以建構沒有這個類別的許可權字串,但許可權的順序是特定的,而且這個類別保證正確性。 |
| AccountSASResourceTypes |
僅適用於運行時間NODE.JS。 這是協助程序類別,用來建構代表 AccountSAS 可存取之資源的字串。 將值設定為 true 表示任何使用這些許可權的 SAS 都會授與該資源類型的存取權。 設定所有值之後,應該使用 toString 串行化,並設定為 <xref:IAccountSASSignatureValues> 物件上的資源欄位。 可以建構沒有這個類別的資源字串,但資源的順序是特定的,而且這個類別保證正確性。 |
| AccountSASServices |
僅適用於運行時間NODE.JS。 這是協助程序類別,用來建構代表 AccountSAS 可存取之服務的字串。 將值設定為 true 表示任何使用這些許可權的 SAS 都會授與該服務的存取權。 設定所有值之後,應該使用 toString 串行化,並將 設定為 <xref:IAccountSASSignatureValues> 物件上的服務欄位。 可以建構沒有這個類別的服務字串,但服務的順序是特別的,而這個類別保證正確性。 |
| BrowserPolicyFactory |
BrowserPolicyFactory 是可協助產生 BrowserPolicy 物件的 Factory 類別。 |
| DirectoryURL |
DirectoryURL 代表 Azure 記憶體目錄的 URL,可讓您作其檔案和目錄。 |
| FileSASPermissions |
僅適用於運行時間NODE.JS。 這是協助程序類別,用來建構字串,代表 ServiceSAS 授與給檔案的許可權。 將值設定為 true 表示任何使用這些許可權的 SAS 都會授與該作業的許可權。 設定所有值之後,應該使用 toString 串行化,並設定為 <xref:IFileSASSignatureValues> 對象的許可權欄位。 可以建構沒有這個類別的許可權字串,但許可權的順序是特定的,而且這個類別保證正確性。 |
| FileSystemAttributes |
這是協助程式類別,用來建構字串,代表檔案或目錄的NTFS屬性。 |
| FileURL |
FileURL 代表 Azure 記憶體檔案的 URL。 |
| KeepAlivePolicyFactory |
KeepAlivePolicyFactory 是一種處理站類別,可協助產生 KeepAlivePolicy 物件。 |
| LoggingPolicyFactory |
LoggingPolicyFactory 是一種處理站類別,可協助產生LoggingPolicy物件。 |
| Pipeline |
包含 HTTP 要求原則的 Pipeline 類別。 您可以呼叫 StorageURL.newPipeline()來建立預設管線。 或者,您可以透過管線的建構函式,使用您自己的原則建立管線。 請參閱 StorageURL.newPipeline(),並在實作自定義管線之前提供原則作為參考。 |
| RetryPolicyFactory |
RetryPolicyFactory 是一種處理站類別,可協助產生 RetryPolicy 物件。 |
| SASQueryParameters |
表示組成 Azure 記憶體 SAS 查詢參數的元件。 使用者不會直接建構此類型;它只會由 <xref:IAccountSASSignatureValues> 和 <xref:IFileSASSignatureValues> 類型產生。 產生之後,它可以編碼成 {@code String} 並直接附加至 URL(不過,如果現有的查詢參數存在,則應該在此小心,這可能會影響附加這些查詢參數的適當方法)。 注意:這個類別的實例是不可變的。 |
| ServiceURL |
ServiceURL 代表 Azure 記憶體檔案服務的 URL,可讓您作檔案共用。 |
| ShareSASPermissions |
這是協助程序類別,用來建構字串,代表 ServiceSAS 授與給共用的許可權。 將值設定為 true 表示任何使用這些許可權的 SAS 都會授與該作業的許可權。 設定所有值之後,應該使用 toString 串行化,並設定為 <xref:IFileSASSignatureValues> 對象的許可權欄位。 可以建構沒有這個類別的許可權字串,但許可權的順序是特定的,而且這個類別保證正確性。 |
| ShareURL |
ShareURL 代表 Azure 記憶體共用的 URL,可讓您作其目錄和檔案。 |
| StorageURL |
ServiceURL 代表 ServiceURL、ContainerURL 等的基底 URL 類別。 |
| TelemetryPolicyFactory |
TelemetryPolicyFactory 是一種處理站類別,可協助產生 TelemetryPolicy 物件。 |
| UniqueRequestIDPolicyFactory |
UniqueRequestIDPolicyFactory 是一種處理站類別,可協助產生 UniqueRequestIDPolicy 物件。 |
| AnonymousCredential |
AnonymousCredential 提供 credentialPolicyCreator 成員,用來建立 AnonymousCredentialPolicy 物件。 AnonymousCredentialPolicy 會與讀取公用資源的 HTTP(S) 要求搭配使用,或用於共用存取簽章(SAS)。 |
| Credential |
Credential 是 Azure 記憶體 HTTP 要求簽署的抽象類。 此類別會裝載一個 credentialPolicyCreator Factory,其會產生 CredentialPolicy。 |
| SharedKeyCredential |
僅適用於運行時間NODE.JS。 Azure 記憶體服務帳戶密鑰授權的 SharedKeyCredential。 |
| Directory |
代表目錄的類別。 |
| File |
代表檔案的類別。 |
| Service |
代表服務的類別。 |
| Share |
代表共用的類別。 |
| StorageClient | |
| StorageClientContext | |
| AnonymousCredentialPolicy |
AnonymousCredentialPolicy 會與讀取公用資源的 HTTP(S) 要求搭配使用,或用於共用存取簽章(SAS)。 |
| BrowserPolicy |
BrowserPolicy 會處理 Node.js 與瀏覽器運行時間之間的差異,包括:
|
| CredentialPolicy |
在傳送之前,用來簽署 HTTP(S) 要求的認證原則。 這是抽象類。 |
| KeepAlivePolicy |
KeepAlivePolicy 是用來控制每個要求保持運作設定的原則。 |
| LoggingPolicy |
LoggingPolicy 是用來記錄要求的原則。 |
| RetryPolicy |
重試原則,並實作指數重試和線性重試。 |
| SharedKeyCredentialPolicy |
SharedKeyCredentialPolicy 是用來使用共用密鑰簽署 HTTP 要求的原則。 |
| TelemetryPolicy |
TelemetryPolicy 是用來標記每個要求之使用者代理程序標頭的原則。 |
| UniqueRequestIDPolicy |
UniqueRequestIDPolicy 會產生 UUID 作為 x-ms-request-id 標頭值。 |
| Batch |
Batch 提供具有並行限制的基本平行執行。 當其中一個執行作業擲回錯誤時,將會停止執行左側作業。 但是 Batch 無法取消進行中的作業,您必須自行取消它們。 |
| BufferScheduler |
這個類別接受 Node.js 可讀取數據流做為輸入,並持續將數據從數據流讀取到內部緩衝區結構,直到達到 maxBuffers 為止。 每個可用的緩衝區都會嘗試觸發 outgoingHandler。 內部緩衝區結構包含傳入緩衝區陣列和傳出緩衝區陣列。 傳入緩衝區陣列包含「空白」緩衝區,可以填入新的傳入數據。 傳出陣列包含要由 outgoingHandler 處理的填滿緩衝區。 上述每個緩衝區大小都是由參數bufferSize所定義。 NUM_OF_ALL_BUFFERS = BUFFERS_IN_INCOMING + BUFFERS_IN_OUTGOING + BUFFERS_UNDER_HANDLING <NUM_OF_ALL_BUFFERS = 最大緩衝區 效能改進秘訣:
|
| RetriableReadableStream |
僅適用於運行時間NODE.JS。 當內部 ReadableStream 非預期結束時,Node.js ReadableStream 會在內部重試。 |
介面
類型別名
| FileDownloadResponse |
包含下載作業的回應數據。 |
| FileGetRangeListResponse |
包含 getRangeList 作業的響應數據。 |
| ShareGetAccessPolicyResponse |
包含 getAccessPolicy 作業的響應數據。 |
| ShareGetStatisticsResponse |
包含 getStatistics 作業的響應數據。 |
| CredentialPolicyCreator |
建立使用所提供 nextPolicy 之新 CredentialPolicy 的 Factory 函式。 |
| CopyStatusType |
定義 CopyStatusType 的值。 可能的值包括:'pending'、'success'、'aborted'、'failed' |
| DeleteSnapshotsOptionType |
定義DeleteSnapshotsOptionType的值。 可能的值包括:'include' |
| DirectoryCreateResponse |
包含建立作業的響應數據。 |
| DirectoryDeleteResponse |
包含 deleteMethod 作業的響應數據。 |
| DirectoryForceCloseHandlesResponse |
包含 forceCloseHandles 作業的響應數據。 |
| DirectoryGetPropertiesResponse |
包含 getProperties 作業的響應數據。 |
| DirectoryListFilesAndDirectoriesSegmentResponse |
包含 listFilesAndDirectoriesSegment 作業的響應數據。 |
| DirectoryListHandlesResponse |
包含 listHandles 作業的響應數據。 |
| DirectorySetMetadataResponse |
包含 setMetadata 作業的響應數據。 |
| DirectorySetPropertiesResponse |
包含 setProperties 作業的響應數據。 |
| FileAbortCopyResponse |
包含abortCopy作業的響應數據。 |
| FileCreateResponse |
包含建立作業的響應數據。 |
| FileDeleteResponse |
包含 deleteMethod 作業的響應數據。 |
| FileForceCloseHandlesResponse |
包含 forceCloseHandles 作業的響應數據。 |
| FileGetPropertiesResponse |
包含 getProperties 作業的響應數據。 |
| FileListHandlesResponse |
包含 listHandles 作業的響應數據。 |
| FileRangeWriteType |
定義 FileRangeWriteType 的值。 可能的值包括:'update'、'clear' |
| FileSetHTTPHeadersResponse |
包含 setHTTPHeaders 作業的響應數據。 |
| FileSetMetadataResponse |
包含 setMetadata 作業的響應數據。 |
| FileStartCopyResponse |
包含 startCopy 作業的響應數據。 |
| FileType |
定義 FileType 的值。 可能的值包括:'File' |
| FileUploadRangeFromURLResponse |
包含 uploadRangeFromURL 作業的響應數據。 |
| FileUploadRangeResponse |
包含 uploadRange 作業的響應數據。 |
| ListSharesIncludeType |
定義 ListSharesIncludeType 的值。 可能的值包括:'snapshots'、'metadata' |
| ServiceGetPropertiesResponse |
包含 getProperties 作業的響應數據。 |
| ServiceListSharesSegmentResponse |
包含 listSharesSegment 作業的響應數據。 |
| ServiceSetPropertiesResponse |
包含 setProperties 作業的響應數據。 |
| ShareCreatePermissionResponse |
包含 createPermission 作業的響應數據。 |
| ShareCreateResponse |
包含建立作業的響應數據。 |
| ShareCreateSnapshotResponse |
包含 createSnapshot 作業的響應數據。 |
| ShareDeleteResponse |
包含 deleteMethod 作業的響應數據。 |
| ShareGetPermissionResponse |
包含 getPermission 作業的響應數據。 |
| ShareGetPropertiesResponse |
包含 getProperties 作業的響應數據。 |
| ShareSetAccessPolicyResponse |
包含 setAccessPolicy 作業的響應數據。 |
| ShareSetMetadataResponse |
包含 setMetadata 作業的響應數據。 |
| ShareSetQuotaResponse |
包含 setQuota 作業的響應數據。 |
| StorageErrorCode |
定義 StorageErrorCode 的值。 可能的值包括:'AccountAlreadyExists'、'AccountBeingCreated'、'AccountIsDisabled'、'AuthenticationFailed'、'AuthorizationFailure'、'ConditionHeadersNotSupported'、 'ConditionNotMet'、'EmptyMetadataKey'、'InsufficientAccountPermissions'、'InternalError'、'InvalidAuthenticationInfo'、'InvalidHeaderValue'、'InvalidHttpVerb'、'InvalidInput'、'InvalidMd5'、'InvalidMetadata'、'InvalidQueryParameterValue'、'InvalidRange'、'InvalidResourceName'、'InvalidUri'、'InvalidXmlDocument'、'InvalidXmlNodeValue'、'Md5Mismatch'、'MetadataTooLarge'、'MissingContentLengthHeader'、'MissingRequiredQueryParameter'、'MissingRequiredHeader'、'MissingRequiredXmlNode'、 'MultipleConditionHeadersNotSupported', 'OperationTimedOut', 'OutOfRangeInput', 'OutOfRangeQueryParameterValue', 'RequestBodyTooLarge', 'ResourceTypeMismatch', 'RequestUrlFailedToParse', 'ResourceAlreadyExists', 'ResourceNotFound', 'ServerBusy', 'UnsupportedHeader', 'UnsupportedXmlNode'、'UnsupportedQueryParameter'、'UnsupportedHttpVerb'、'CannotDeleteFileOrDirectory'、'ClientCacheFlushDelay'、'DeletePending'、'DirectoryNotEmpty'、'FileLockConflict'、'InvalidFileOrDirectoryPathName'、 'ParentNotFound'、'ReadOnlyAttribute'、'ShareAlreadyExists'、'ShareBeingDeleted'、'ShareDisabled'、'ShareNotFound'、'SharingViolation'、'ShareSnapshotInProgress'、'ShareSnapshotCountExceeded'、'ShareSnapshotOperationNotSupported'、'ShareHasSnapshots', 'ContainerQuotaDowngradeNotAllowed' |
| FileAttributesPreserveType |
表示保留現有的檔案屬性不變。 |
| FilePermissionInheritType |
表示繼承父目錄的檔案許可權。 |
| FilePermissionPreserveType |
表示保留現有的檔案許可權值不變。 |
| TimeNowType |
表示將 設定為要求的時間。 |
| TimePreserveType |
表示保留現有的時間值不變。 |
| Operation |
作業是由 Batch 執行和管理的異步函式。 |
| OutgoingHandler |
OutgoingHandler 是由 BufferScheduler 觸發的異步函式。 |
| ReadableStreamGetter | |
列舉
| SASProtocol |
產生的 SAS 通訊協定。 |
| RetryPolicyType |
RetryPolicy 類型。 |
函式
| generate |
僅適用於運行時間NODE.JS。 產生 <xref:SASQueryParameters> 物件,其中包含發出實際 REST 要求所需的所有 SAS 查詢參數。 |
| generate |
僅適用於運行時間NODE.JS。 建立 SASQueryParameters 的實例。 只接受建立 SAS 所需的必要設定。 如需選擇性設定,請直接設定對應的屬性,例如許可權、startTime 和標識符。 警告:未提供標識符時,需要許可權和 expiryTime。 如果您以這個建構函式初始,則必須手動將值指派給標識碼或 expiryTime & 許可權。 |
| ip |
產生IPRange格式字串。 例如:“8.8.8.8” 或 “1.1.1.1-255.255.255.255” |
| range |
產生範圍字串。 例如:“bytes=255-” 或 “bytes=0-511” |
| upload |
僅適用於瀏覽器。 將瀏覽器 Blob/File/ArrayBuffer/ArrayBufferView 對象上傳至 Azure 檔案。 |
| download |
僅適用於運行時間NODE.JS。 平行下載 Azure 檔案至緩衝區。 位移和計數是選擇性的,兩者都傳遞 0 以下載整個檔案。 |
| upload |
僅適用於運行時間NODE.JS。 將本機檔案上傳至 Azure 檔案。 |
| upload |
僅適用於運行時間NODE.JS。
將 Node.js 可讀取數據流上傳至 Azure 檔案。
此方法會嘗試建立 Azure,然後依區塊開始上傳區塊。
區塊的大小是由 效能改進秘訣:
|
| file |
|
| file |
|
| file |
|
| validate |
|
| validate |
|
| validate |
|
| New |
用來產生 RetryPolicy 處理站的 Factory 方法。 |
| blob |
將 Browser Blob 物件轉換成 ArrayBuffer。 |
| append |
將字串附加至 URL 路徑。 當 URL 路徑以 「結尾時,將會移除字串前面重複的」 / /。 |
| base64decode(string) | Base64 譯碼。 |
| base64encode(string) | Base64 編碼。 |
| delay(number, Abort |
延遲指定的時間間隔。 |
| escape |
針對 Blob 或檔案等記憶體服務,必須正確逸出保留的 URL 字元。 JSv10 SDK 的 URL 編碼和逸出策略當客戶將 URL 字串傳遞至 XXXURL 類別建構函式時,URL 字串可能已經編碼或未編碼。 但在傳送至 Azure 記憶體伺服器之前,URL 必須經過編碼。 不過,SDK 很難猜測 URL 字串是否已編碼。 我們有 2 個潛在策略,並為 XXXURL 建構函式選擇策略 2 個。 策略一:假設客戶 URL 字串未編碼,且一律在 SDK 中編碼 URL 字串。這是舊版 V2 SDK 的功能,簡單且適用於大部分的情況。
但是,此策略將無法建立名稱為 “?” 的 Blob。 因為當客戶 URL 字串是 「http://account.blob.core.windows.net/con/blob?name",」?name」 會被視為 URL 參數,而不是 Blob 名稱。 如果客戶 URL 字串為 「http://account.blob.core.windows.net/con/blob%3Fname",則會建立名為 」blob%3Fname“ 的 Blob。 V2 SDK 沒有此問題,因為它不允許客戶傳入完整的 URL,因此它接受個別的 Blob 名稱和 encodeURIComponent。 我們無法接受 SDK 無法使用 “?”建立 Blob 名稱。 因此,我們會實作兩個策略: 策略二:SDK 不會假設 URL 已編碼或未編碼。 它只會逸出特殊字元。這是 V10 Blob Go SDK 的功能。 它會接受 Go 中的 URL 類型,並呼叫 URL。EscapedPath() 以逸出特殊字元未逸出。
此策略可讓我們彈性地使用任何特殊字元來建立。 但是“%” 會被視為特殊字元,如果 URL 字串未編碼,則 URL 字串中不應該有 “%”,否則 URL 不是有效的 URL。 如果客戶需要在 Blob 名稱中建立具有 「%」 的 Blob,請使用 「%25」 insead of “%”。 就像上述第 3 個範例一樣。 下列 URL 字串無效:
另一個特殊字元是 “?”,請使用 “%2F” 來代表 URL 字串中含有 “?” 的 Blob 名稱。 containerName、blobName 或其他方法中特定 XXXName 參數的策略,例如
|
| get |
依名稱取得URL參數。 |
| get |
從 URL 字串取得 URL 路徑。 |
| get |
從 URL 字串取得 URL 查詢索引鍵值組。 |
| pad |
String.prototype.padStart() |
| set |
設定 URL 主機。 |
| set |
設定 URL 參數名稱和值。 如果名稱存在於 URL 參數中,舊值將會由名稱索引鍵取代。 如果未提供值,則會刪除 參數。 |
| truncatedISO8061Date(Date, undefined | false | true) | 將日期捨入為秒數。 |
| stream |
將可讀取數據流讀入緩衝區。 從位移到結尾填入緩衝區。 |
函式詳細資料
generateAccountSASQueryParameters(IAccountSASSignatureValues, SharedKeyCredential)
僅適用於運行時間NODE.JS。 產生 <xref:SASQueryParameters> 物件,其中包含發出實際 REST 要求所需的所有 SAS 查詢參數。
function generateAccountSASQueryParameters(accountSASSignatureValues: IAccountSASSignatureValues, sharedKeyCredential: SharedKeyCredential)
參數
- accountSASSignatureValues
- IAccountSASSignatureValues
- sharedKeyCredential
- SharedKeyCredential
傳回
generateFileSASQueryParameters(IFileSASSignatureValues, SharedKeyCredential)
僅適用於運行時間NODE.JS。 建立 SASQueryParameters 的實例。
只接受建立 SAS 所需的必要設定。 如需選擇性設定,請直接設定對應的屬性,例如許可權、startTime 和標識符。
警告:未提供標識符時,需要許可權和 expiryTime。 如果您以這個建構函式初始,則必須手動將值指派給標識碼或 expiryTime & 許可權。
function generateFileSASQueryParameters(fileSASSignatureValues: IFileSASSignatureValues, sharedKeyCredential: SharedKeyCredential)
參數
- fileSASSignatureValues
- IFileSASSignatureValues
- sharedKeyCredential
- SharedKeyCredential
傳回
ipRangeToString(IIPRange)
產生IPRange格式字串。 例如:“8.8.8.8” 或 “1.1.1.1-255.255.255.255”
function ipRangeToString(ipRange: IIPRange)
參數
- ipRange
- IIPRange
傳回
string
rangeToString(IRange)
產生範圍字串。 例如:“bytes=255-” 或 “bytes=0-511”
function rangeToString(iRange: IRange)
參數
- iRange
- IRange
傳回
string
uploadBrowserDataToAzureFile(Aborter, Blob | ArrayBuffer | ArrayBufferView, FileURL, IUploadToAzureFileOptions)
僅適用於瀏覽器。 將瀏覽器 Blob/File/ArrayBuffer/ArrayBufferView 對象上傳至 Azure 檔案。
function uploadBrowserDataToAzureFile(aborter: Aborter, browserData: Blob | ArrayBuffer | ArrayBufferView, fileURL: FileURL, options?: IUploadToAzureFileOptions)
參數
- aborter
- Aborter
使用 Aborter.none 或 Aborter.timeout() 建立新的 Aborter 實例,以取得更多關於要求取消的範例,請參閱 Aborter 的檔
- browserData
-
Blob | ArrayBuffer | ArrayBufferView
Blob、檔案、ArrayBuffer 或 ArrayBufferView
- fileURL
- FileURL
- options
- IUploadToAzureFileOptions
傳回
Promise<void>
downloadAzureFileToBuffer(Aborter, Buffer, FileURL, number, undefined | number, IDownloadFromAzureFileOptions)
僅適用於運行時間NODE.JS。 平行下載 Azure 檔案至緩衝區。 位移和計數是選擇性的,兩者都傳遞 0 以下載整個檔案。
function downloadAzureFileToBuffer(aborter: Aborter, buffer: Buffer, fileURL: FileURL, offset: number, count?: undefined | number, options?: IDownloadFromAzureFileOptions)
參數
- aborter
- Aborter
使用 Aborter.none 或 Aborter.timeout() 建立新的 Aborter 實例,以取得更多關於要求取消的範例,請參閱 Aborter 的檔
- buffer
-
Buffer
要填滿的緩衝區,長度必須大於計數
- fileURL
- FileURL
FileURL 物件
- offset
-
number
要下載的 Azure 檔案位置
- count
-
undefined | number
- options
- IDownloadFromAzureFileOptions
傳回
Promise<void>
uploadFileToAzureFile(Aborter, string, FileURL, IUploadToAzureFileOptions)
僅適用於運行時間NODE.JS。 將本機檔案上傳至 Azure 檔案。
function uploadFileToAzureFile(aborter: Aborter, filePath: string, fileURL: FileURL, options?: IUploadToAzureFileOptions)
參數
- aborter
- Aborter
使用 Aborter.none 或 Aborter.timeout() 建立新的 Aborter 實例,以取得更多關於要求取消的範例,請參閱 Aborter 的檔
- filePath
-
string
本機檔案的完整路徑
- fileURL
- FileURL
FileURL
- options
- IUploadToAzureFileOptions
傳回
Promise<void>
uploadStreamToAzureFile(Aborter, Readable, number, FileURL, number, number, IUploadStreamToAzureFileOptions)
僅適用於運行時間NODE.JS。
將 Node.js 可讀取數據流上傳至 Azure 檔案。
此方法會嘗試建立 Azure,然後依區塊開始上傳區塊。
區塊的大小是由 bufferSize 參數所定義。
請確定數據流的潛在大小不會超過檔案大小。
效能改進秘訣:
- 輸入數據流 highWaterMark 最好使用 bufferSize 參數設定相同的值,以避免 Buffer.concat() 作業。
function uploadStreamToAzureFile(aborter: Aborter, stream: Readable, size: number, fileURL: FileURL, bufferSize: number, maxBuffers: number, options?: IUploadStreamToAzureFileOptions)
參數
- aborter
- Aborter
使用 Aborter.none 或 Aborter.timeout() 建立新的 Aborter 實例,以取得更多關於要求取消的範例,請參閱 Aborter 的檔
- stream
-
Readable
Node.js 可讀取數據流。 必須小於或等於檔案大小。
- size
-
number
要建立的檔案大小。 允許的最大大小為 1TB。 如果這個值大於數據流大小,檔案結尾中將會有空的位元組。
- fileURL
- FileURL
FileURL 實例
- bufferSize
-
number
每個以位元組配置的緩衝區大小,也是上傳的檔案期間區塊/範圍大小。 大小必須 > 0,<= 4 * 1024 * 1024 (4MB)
- maxBuffers
-
number
最大緩衝區會在上傳期間配置,與上傳並行上限的正相互關聯
- options
- IUploadStreamToAzureFileOptions
傳回
Promise<void>
fileAttributesToString(FileSystemAttributes | FileAttributesPreserveType)
function fileAttributesToString(fileAttributes: FileSystemAttributes | FileAttributesPreserveType)
參數
- fileAttributes
傳回
string
fileCreationTimeToString(Date | TimeNowType | TimePreserveType)
function fileCreationTimeToString(time: Date | TimeNowType | TimePreserveType)
參數
- time
-
Date | TimeNowType | TimePreserveType
傳回
string
fileLastWriteTimeToString(Date | TimeNowType | TimePreserveType)
function fileLastWriteTimeToString(time: Date | TimeNowType | TimePreserveType)
參數
- time
-
Date | TimeNowType | TimePreserveType
傳回
string
validateAndSetDefaultsForFileAndDirectoryCreateCommonOptions(IFileAndDirectoryCreateCommonOptions)
function validateAndSetDefaultsForFileAndDirectoryCreateCommonOptions(options: IFileAndDirectoryCreateCommonOptions)
參數
傳回
validateAndSetDefaultsForFileAndDirectorySetPropertiesCommonOptions(IFileAndDirectorySetPropertiesCommonOptions)
function validateAndSetDefaultsForFileAndDirectorySetPropertiesCommonOptions(options: IFileAndDirectorySetPropertiesCommonOptions)
參數
傳回
validateFilePermissionOptions(undefined | string, undefined | string)
function validateFilePermissionOptions(filePermission?: undefined | string, filePermissionKey?: undefined | string)
參數
- filePermission
-
undefined | string
- filePermissionKey
-
undefined | string
NewRetryPolicyFactory(IRetryOptions)
用來產生 RetryPolicy 處理站的 Factory 方法。
function NewRetryPolicyFactory(retryOptions?: IRetryOptions)
參數
- retryOptions
- IRetryOptions
傳回
RequestPolicyFactory
blobToArrayBuffer(Blob)
將 Browser Blob 物件轉換成 ArrayBuffer。
function blobToArrayBuffer(blob: Blob)
參數
- blob
-
Blob
傳回
Promise<ArrayBuffer>
appendToURLPath(string, string)
將字串附加至 URL 路徑。 當 URL 路徑以 「結尾時,將會移除字串前面重複的」 / /。
function appendToURLPath(url: string, name: string)
參數
- url
-
string
來源 URL 字串
- name
-
string
要附加至 URL 的字串
傳回
string
更新的 URL 字串
base64decode(string)
Base64 譯碼。
function base64decode(encodedString: string)
參數
- encodedString
-
string
傳回
string
base64encode(string)
Base64 編碼。
function base64encode(content: string)
參數
- content
-
string
傳回
string
delay(number, AbortSignalLike, Error)
延遲指定的時間間隔。
function delay(timeInMs: number, aborter?: AbortSignalLike, abortError?: Error)
參數
- timeInMs
-
number
- aborter
-
AbortSignalLike
- abortError
-
Error
傳回
Promise<unknown>
escapeURLPath(string)
針對 Blob 或檔案等記憶體服務,必須正確逸出保留的 URL 字元。
JSv10 SDK 的 URL 編碼和逸出策略
當客戶將 URL 字串傳遞至 XXXURL 類別建構函式時,URL 字串可能已經編碼或未編碼。 但在傳送至 Azure 記憶體伺服器之前,URL 必須經過編碼。 不過,SDK 很難猜測 URL 字串是否已編碼。 我們有 2 個潛在策略,並為 XXXURL 建構函式選擇策略 2 個。
策略一:假設客戶 URL 字串未編碼,且一律在 SDK 中編碼 URL 字串。
這是舊版 V2 SDK 的功能,簡單且適用於大部分的情況。
- 當客戶 URL 字串為 「http://account.blob.core.windows.net/con/b:", SDK 會將它編碼為 」http://account.blob.core.windows.net/con/b%3A"和傳送至伺服器。 將會建立名為 “b:” 的 Blob。
- 當客戶 URL 字串為 「http://account.blob.core.windows.net/con/b%3A", SDK 會將它編碼為 」http://account.blob.core.windows.net/con/b%253A"和傳送至伺服器。 將會建立名為 「b%3A」 的 Blob。
但是,此策略將無法建立名稱為 “?” 的 Blob。 因為當客戶 URL 字串是 「http://account.blob.core.windows.net/con/blob?name",」?name」 會被視為 URL 參數,而不是 Blob 名稱。 如果客戶 URL 字串為 「http://account.blob.core.windows.net/con/blob%3Fname",則會建立名為 」blob%3Fname“ 的 Blob。 V2 SDK 沒有此問題,因為它不允許客戶傳入完整的 URL,因此它接受個別的 Blob 名稱和 encodeURIComponent。 我們無法接受 SDK 無法使用 “?”建立 Blob 名稱。 因此,我們會實作兩個策略:
策略二:SDK 不會假設 URL 已編碼或未編碼。 它只會逸出特殊字元。
這是 V10 Blob Go SDK 的功能。 它會接受 Go 中的 URL 類型,並呼叫 URL。EscapedPath() 以逸出特殊字元未逸出。
- 當客戶 URL 字串為 「http://account.blob.core.windows.net/con/b:", SDK 會逸出 」:“,例如 「http://account.blob.core.windows.net/con/b%3A"和傳送至伺服器。 將會建立名為 “b:” 的 Blob。
- 當客戶 URL 字串為 「http://account.blob.core.windows.net/con/b%3A", 沒有特殊字元,因此傳送 」http://account.blob.core.windows.net/con/b%3A"至伺服器。 將會建立名為 “b:” 的 Blob。
- 當客戶 URL 字串為 「http://account.blob.core.windows.net/con/b%253A", 沒有特殊字元,因此傳送 」http://account.blob.core.windows.net/con/b%253A"至伺服器。 將會建立名為 「b%3A」 的 Blob。
此策略可讓我們彈性地使用任何特殊字元來建立。 但是“%” 會被視為特殊字元,如果 URL 字串未編碼,則 URL 字串中不應該有 “%”,否則 URL 不是有效的 URL。 如果客戶需要在 Blob 名稱中建立具有 「%」 的 Blob,請使用 「%25」 insead of “%”。 就像上述第 3 個範例一樣。 下列 URL 字串無效:
- “http://account.blob.core.windows.net/con/b%"
- “http://account.blob.core.windows.net/con/b%2"
- “http://account.blob.core.windows.net/con/b%G"
另一個特殊字元是 “?”,請使用 “%2F” 來代表 URL 字串中含有 “?” 的 Blob 名稱。
containerName、blobName 或其他方法中特定 XXXName 參數的策略,例如 BlobURL.fromContainerURL(containerURL, blobName)
我們將套用策略一,並針對 blobName 等這些參數呼叫 encodeURIComponent。 因為客戶傳入的內容是純名,而不是URL。
function escapeURLPath(url: string)
參數
- url
-
string
傳回
string
getURLParameter(string, string)
依名稱取得URL參數。
function getURLParameter(url: string, name: string)
參數
- url
-
string
- name
-
string
傳回
string | string[] | undefined
getURLPath(string)
從 URL 字串取得 URL 路徑。
function getURLPath(url: string)
參數
- url
-
string
來源 URL 字串
傳回
string | undefined
getURLQueries(string)
從 URL 字串取得 URL 查詢索引鍵值組。
function getURLQueries(url: string)
參數
- url
-
string
傳回
[key: string]: string
padStart(string, number, undefined | string)
String.prototype.padStart()
function padStart(currentString: string, targetLength: number, padString?: undefined | string)
參數
- currentString
-
string
- targetLength
-
number
- padString
-
undefined | string
傳回
string
setURLHost(string, string)
設定 URL 主機。
function setURLHost(url: string, host: string)
參數
- url
-
string
來源 URL 字串
- host
-
string
新的主機字串
傳回
string
更新的 URL 字串
setURLParameter(string, string, undefined | string)
設定 URL 參數名稱和值。 如果名稱存在於 URL 參數中,舊值將會由名稱索引鍵取代。 如果未提供值,則會刪除 參數。
function setURLParameter(url: string, name: string, value?: undefined | string)
參數
- url
-
string
來源 URL 字串
- name
-
string
參數名稱
- value
-
undefined | string
傳回
string
更新的 URL 字串
truncatedISO8061Date(Date, undefined | false | true)
將日期捨入為秒數。
function truncatedISO8061Date(date: Date, withMilliseconds?: undefined | false | true)
參數
- date
-
Date
- withMilliseconds
-
undefined | false | true
傳回
string
ISO8061格式的日期字串,包含或不含 7 毫秒元件
streamToBuffer(ReadableStream, Buffer, number, number, undefined | string)
將可讀取數據流讀入緩衝區。 從位移到結尾填入緩衝區。
function streamToBuffer(stream: ReadableStream, buffer: Buffer, offset: number, end: number, encoding?: undefined | string)
參數
- stream
-
ReadableStream
Node.js 可讀取數據流
- buffer
-
Buffer
要填滿的緩衝區,長度必須 >= offset
- offset
-
number
要填滿之緩衝區中的位置,包含
- end
-
number
要填滿之緩衝區中的位置,獨佔
- encoding
-
undefined | string
傳回
Promise<void>