Closed xiebruce closed 5 years ago
If you upload without the content-type
header, you will carry the application/octet-stream
by default, which will be automatically converted to the corresponding content-type
when you download it.
这还得自己指定啊,我看别的云都是默认文件本身的content-type的,因为你用application/octet-stream
的话,会导致在网页上查看不了图片,会变成下载,有时候想看看图片就不方便。我用aws s3兼容接口上传就正常,文件本来的mime是什么上传后就是什么,都不用自己指定,所以你们这个这么搞有点不太科学
感谢您的建议,这个地方的产品策略我们先内部对齐一下
好的,谢谢!
这应该是guzzle6版本phpsdk的一个bug,默认会携带application/octet-stream
的头部去上传。现在已经修复,如果不带cotent-type上传的文件,浏览器下载时会默认预览
修复了后面再发版本是吗?
可以先用一下dev的版本,这边ut覆盖率上去后就会release2.0.0
好的
临时决解方案是修改Qcloud\Cos\Request\BodyLocation.php的第48行
$request = $request->withHeader('Content-Type', 'application/octet-stream');
修改为如下代码即可变更header
$request = $request->withHeader('Content-Type', $command->hasParam('contenttype')?$command['contenttype']:'application/octet-stream');
之后用链接便可直接浏览不再下载
@nagatoyk 官方已经解决了
如图,上传图片,假如是jpg的,content-type应该是
image/jpeg
,png图片应该是image/png
,gif应该是image/gif
,而不是全都是application/octet-stream
:上传代码如下: