我正在使用Amazon S3存储桶来存储用户上传的文件以供公共访问。
当您单击指向该资源的链接时,即使可以在浏览器中查看文件(例如JPG等),它也似乎会强制下载。
正如TheZuck指出的那样,问题在于上传文件时未设置内容类型。
我正在使用Amazon S3 PHP类(http://undesigned.org.za/2007/10/22/amazon-s3-php-class),因此mime_content_type($file)
在使用putObjectFile时只需添加内容类型(在PHP中)方法:
$s3class->putObjectFile($file, S3BUCKET, $target_location, S3::ACL_PUBLIC_READ, NULL, mime_content_type($file));
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句