douyujun0152 2013-06-07 20:23
浏览 87
已采纳

如何在PHP中使用Amazon S3 UploadBuilder时设置存储类

I'm using the PHP SDK 2 for Amazon S3, in particular the UploadBuilder class to do multipart concurrent uploading of files. How, if you can, do you set the storage class of the file that you are uploading? When you do a regular putObject, you can set the storage class that you want the file to have. I want my files to be stored using reduced redundancy rather than the standard storage. Can I just use setOption to set a header like so?

setOption('x-amz-storage-class', 'REDUCED_REDUNDANCY')

From looking at the source of UploadBuilder it appears you may be able to set it using Metadata. Here's an example of setting an MD5 header from the source:

// If an MD5 is specified, then add it to the custom headers of the request
// so that it will be returned when downloading the object from Amazon S3
if ($this->md5) {
    $params['Metadata']['x-amz-Content-MD5'] = $this->md5;
}

So, that would mean I would set it doing something like this:

setOption('Metadata', array('x-amz-storage-class' => 'REDUCED_REDUNDANCY'))

Can anyone confirm this is correct or am I way off base?

  • 写回答

1条回答 默认 最新

  • doulouli8686 2013-06-08 14:41
    关注

    In the API docs for setOption, it says that the method sets "an option to pass to the initial CreateMultipartUpload operation". According to the API docs for createMultipartUpload, you should use the StorageClass param. So, you should be able to do the following with the UploadBuilder to set the storage class on your multipart upload:

    ->setOption('StorageClass', 'REDUCED_REDUNDANCY')

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 已有python代码,要求做成可执行程序,程序设计内容不多
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥15 小红薯封设备能解决的来
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助
  • ¥15 STM32控制MAX7219问题求解答
  • ¥20 在本地部署CHATRWKV时遇到了AttributeError: 'str' object has no attribute 'requires_grad'
  • ¥15 vue+element项目中多tag时,切换Tab时iframe套第三方html页面需要实现不刷新
  • ¥50 深度强化学习解决能源调度问题