我可以使用以下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
以上的用户上传文件而不使用连接字符串/容器名称吗?
答案 0 :(得分:1)
不,您不能这样做,原因很简单:/
是容器名称的有效字符。 EG:您可以将容器命名为mycontainer/folder/subFolder