繁体   English   中英

将Blob上传到Windows Azure时指定特定地址

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM