【发布时间】:2019-04-14 08:01:06
【问题描述】:
在重命名之前的图像后,我正在尝试使用 Xamarin Blob 来保存图像的新版本。 例如,我的旧图像位于名为“imagecontainer”的容器中,并且 Id 命名为“xama_452”
what I would like to do is :
1- Rename the old image name : for example 'xama_452_11_2018"
2-Move it in a container "oldcontainer"
3- then save the new image in "imagecontainer"
我已经尝试了一些代码,我可以上传图像/blob,但我无法重命名并将其移动到另一个容器。
protected static async Task<CloudBlockBlob> SaveBlockBlob(string containerName, byte[] blob, string blobTitle)
{
var blobContainer = GetBlobContainer(containerName);
var blockBlob = blobContainer.GetBlockBlobReference(blobTitle);
var oldBlob = blobContainer.GetBlockBlobReference(blockBlob.Uri.ToString());
var newBlob = blobContainer.GetBlockBlobReference(blockBlob.Uri.ToString().Replace(blobTitle, DateTime.UtcNow.ToString()+ blobTitle));
await newBlob.StartCopyAsync(oldBlob);
// here is the methode to upload
// await blockBlob.UploadFromByteArrayAsync(blob, 0, blob.Length).ConfigureAwait(false);
return blockBlob;
}
// method to get blob's container
static CloudBlobContainer GetBlobContainer(string containerName) => BlobClient.GetContainerReference(containerName);
提前致谢
【问题讨论】:
-
这不是我想重命名旧图像文件的原因,如果你能帮助我
标签: c# azure xamarin.forms azure-active-directory azure-storage