替换Azure存储中的内容 [英] Replace the Contents inside Azure Storage

查看:58
本文介绍了替换Azure存储中的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果存在相同名称,是否可以替换文件?我在Azure存储中看不到任何替换方法.这是我的代码:

Is there are any way to replace a file if the same name exists? I can't see any replace method in Azure Storage. Here is my code:

var client = new CloudBlobClient(
      new Uri(" http://sweetapp.blob.core.windows.net/"), credentials);
var container = client.GetContainerReference("cakepictures");
await container.CreateIfNotExistsAsync();
var perm = new BlobContainerPermissions();
perm.PublicAccess = BlobContainerPublicAccessType.Blob;
await container.SetPermissionsAsync(perm);
var blockBlob = container.GetBlockBlobReference(newfilename + i + file.FileType);
using (var fileStream = await file.OpenSequentialReadAsync())
{
    await blockBlob.UploadFromStreamAsync(fileStream);
}

我可以在此代码中添加任何内容,以替换现有的或相同的文件名吗?

Is there anything that I could add into this code so that it replaces existing or same file name?

推荐答案

如果blob存储中存在一个blob,并且如果您上传的文件名称与该blob的名称相同,则旧的blob内容将自动替换为该内容新文件.您不必做任何特别的事情.

If a blob exists in blob storage and if you upload another file with the same name as that of the blob, old blob contents will automatically be replaced with the contents of new file. You don't have to do anything special.

这篇关于替换Azure存储中的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆