[英]Specify specific address when uploading blobs to windows azure
我正在使用.Net。 當您將Blob上傳到Window Azure存儲器時,是否可以為Blob指定特定的地址?
因為我想在文件完成上傳之前獲得文件的鏈接。 我不在乎鏈接是否不起作用,我只想先擁有鏈接。
我聽說這是可能的,但我找不到任何參考。 我被告知要生成文件標識符,然后使用該標識符上傳文件。
提前致謝!
我直接從windowsazure.com上的指南中得到了這個答案。 這是谷歌短語“將文件上傳到azure blob存儲”的第一結果。
我相信,在GetBlockBlobReference
方法中,您可以用所需的blob文件名替換“ myblob”。
// Retrieve storage account from connection string.
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
CloudConfigurationManager.GetSetting("StorageConnectionString"));
// 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);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.