[英]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.