【发布时间】:2017-02-16 03:51:27
【问题描述】:
我们将内容上传到 S3 私有存储桶。上传内容后,我们通过预签名的 url 访问它们。 MP4,当我们通过浏览器访问该 URL 时,图像工作正常。但是当我们尝试访问 SWF 和 PDF 时,浏览器会提示下载内容。 当我们尝试从公共存储桶访问资产时,它也不会发生。
这是默认行为还是有任何解决方案?
我检查了这个doc
获取网址的代码
public function getPresignedUrl($filename, $expires,$bucket=NULL)
{
if($bucket==NULL){
$bucket=$this->bucket;
}
$command = $this->getClient()->getCommand('GetObject', ['Bucket' =>$bucket , 'Key' => $filename]);
$request = $this->getClient()->createPresignedRequest($command, $expires);
return (string) $request->getUri();
}
==============================更新1================ =================
我们正在使用 AWS sdk 的“上传”功能来上传 swf、pdf 和 mp4。
public function upload($filename, $source, $acl = null, array $options = [])
{
if($this->getClient()->upload(
$this->bucket,
$filename,
$source,
!empty($acl) ? $acl : $this->defaultAcl,
$options
)){
return true;
}else{
return false;
}
}
谢谢
【问题讨论】:
标签: php amazon-web-services amazon-s3