I am trying to use Xamarin Blob to save the new version of a image after renaming the previous one. for example my old image is in the container named "imagecontainer" and has Id named like "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"
I have tried some code I can upload a image/blob but I cannot rename it and move it to another container.
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);
Thanks in advance