是否可以设置现有Azure blob的内容部署? [英] Is it possible to set the content disposition of an existing Azure blob?

查看:34
本文介绍了是否可以设置现有Azure blob的内容部署?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基于Stimms的回答如下: Azure Storage API ContentDisposition

和此处提供的信息: Friendly filename when public download Azure blob

我已经能够在上载新文件时设置内容处置。但我也希望能够设置现有文件的内容处置。

blob.Properties.ContentDisposition = string.Format("attachment;filename="{0}"", friendlyName);

在上载文件之前设置时工作正常,但如果我在现有Blob上试用则无效。

是根本不可能更改现有Blob的内容部署,还是我做错了什么?

推荐答案

是。设置ContentDisposition后,只需在blob上调用SetProperties()方法即可。因此您的代码应该是:

            blob.FetchAttributes();//Fetch properties first so that you don't overwrite existing properties when you call SetProperties
            blob.Properties.ContentDisposition = string.Format("attachment;filename="{0}"", friendlyName);
            blob.SetProperties();

这篇关于是否可以设置现有Azure blob的内容部署?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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