[英]Upload multiple files to Azure Blob storage using container's SAS token/URL
[英]upload files azure blob storage using container url
我可以使用以下 C# 代碼將文件上傳到 azure blob 存儲,
// Retrieve storage account from connection string.
CloudStorageAccount storageAccount = CloudStorageAccount.Parse("StorageKey");
// Create the blob client.
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
// Retrieve reference to a previously created container.
CloudBlobContainer container =
blobClient.GetContainerReference("mycontainer");
// Retrieve reference to a blob named "myblob".
CloudBlockBlob blockBlob = container.GetBlockBlobReference("myblob");
// Create or overwrite the "myblob" blob with contents from a local file.
using (var fileStream = System.IO.File.OpenRead(@"path\myfile"))
{
blockBlob.UploadFromStream(fileStream);
}
在這里,我提供 blob 存儲連接字符串和容器名稱。
現在,我可以看到我在Container Properties
下有 URL,
https://test.blob.core.windows.net/containerId
問題,我可以編寫 C# 代碼,讓用戶在URL
上上傳文件而不是使用連接字符串/容器名稱嗎?
不,你不能,原因很簡單: /
是容器名稱的有效字符。 EG:您可以將容器命名為mycontainer/folder/subFolder
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.