1.Motivation | 起因

A requirement from the product department requires download image from AWS S3 bucket, for achieving this requirement, I should set the image content MIME header as Content-Disposition:Attachment.

产品部门有一项需求是从S3上下载图片,为了完成这一需求,需要把图片的MIME头设为Content-Disposition:Attachment

2.Attemption | 尝试

I tried pre-handling before upload the image file to S3 with the metadata by the following method:

尝试了以下面的方法在文件上传到S3之前进行预处理。

var request = new Amazon.S3.Model.PutObjectRequest()
{
FilePath = @"D:\SourceFile.jpg",
BucketName = @"MyBucket",
Key = @"Folder/NewFileName.jpg",
ContentType= "images/jpg",
CannedACL=S3CannedACL.PublicRead,
};
request.Metadata.Add("Cache-Control", "no-store");

But the result shows that the uploaded file is attached a strange metadata as x-amz-meta-Content-Disposition:Attachment, it's not suitable for my propose.

但结果显示上传的文件被附带了奇怪的元数据:x-amz-meta-Content-Disposition:Attachment,这并非我的本意。

3.Resolved | 解决

Finally I found that the request has a property named Header and it has the typical http header keys such as CacheControl and ContentEncoding, certainly the ContentDisposition is in it too. So I modified the assignment as follow and the requirement can be done.

最终发现,请求体中有个名为Header的属性,该属性具有一些典型的http头中的键,像CacheControlContentEncoding,当然ContentDisposition也在其中。于是如下面的代码这样修改了赋值语句,就搞定了这项工作。

request.Headers.ContentDisposition = "attachment";

最新文章

  1. 周末惊魂:因struts2 016 017 019漏洞被入侵,修复。
  2. 四核RP4412开发板使用Xshell连接的com口应与电脑端口一致
  3. 用StackExchange.Redis客户端连接阿里云Redis服务遇到的问题
  4. 使用 CSS3 动感的图片标题动画效果【附源码下载】
  5. Linux查看硬盘型号
  6. php 生成 Json
  7. 自定义cell
  8. 利用gitbash上传项目到github
  9. java springMVC生成二维码
  10. The First Pig Task
  11. [Javascript] Use Number() to convert to Number if possilbe
  12. TortoiseSVN搭建本地版本库及简单操作使用
  13. debian下使用siege进行压力测试
  14. mongodb备份
  15. java多线程(四)-自定义线程池
  16. andrid面试题
  17. H5页面长按导致app崩溃问题解决
  18. 【winform】splitContainer拆分器控件
  19. 学习笔记:AngularJs
  20. Oracle 常用函数备查

热门文章

  1. pdf文件处理--QPDF
  2. AutoIt实现文件上传
  3. 关联函数-web_reg_save_param
  4. range用法(倒序取值)
  5. kafka全部数据清空
  6. Android学习笔记Intent二
  7. ca73a_c++_流的条件状态
  8. c++无法解析的外部符号 "int const bufferSize
  9. Redis系列(五):数据结构List双向链表中基本操作操作命令和源码解析
  10. ZooKeeper开机启动的俩种方式