Skip to content
This repository has been archived by the owner on Aug 22, 2022. It is now read-only.

微信浏览器中,明明是jpg图片,但是上传到七牛后,mimeType变成了PNG,导致图片不能访问 #358

Open
arieslee opened this issue Jul 31, 2014 · 4 comments

Comments

@arieslee
Copy link

微信浏览器中,明明是jpg图片,但是上传到七牛后,mimeType变成了PNG,导致图片不能访问,大小是0

@2betop
Copy link
Contributor

2betop commented Jul 31, 2014

看看这个issue 里面的第二点 #185

jpeg 压缩后体积反而变大了,这是 android 的另外一个 bug, canvas.toDataUrl 不支持 jpeg编码,实际上采用的 png 编码。详情: https://code.google.com/p/android/issues/detail?id=39885

解决方案:引入了一个 jpeg js压缩库,在不支持的的情况下采用此库。但是此库默认没有打包进来,需要自行配置打包方案,将 runtime/html5/androidpatch.js 打包进来。

@arieslee
Copy link
Author

mimeType这个正确了,但是大小还是0,我设置sendAsBinary 试试?

@2betop
Copy link
Contributor

2betop commented Jul 31, 2014

看第一点注意事项:

上传请求内容为空,这是 android 4 的一个bug,只要 file 的 blob数据修改过,通过 xhr2 去发送就有这个问题。 详情:https://code.google.com/p/android/issues/detail?id=39882

解决方案: 发送的时候采用二进制方案,即 把 sendAsBinary 设置成true, 通过这种方式可以避免这个问题。后端接受需要小改动一下, 改成接受流的方式。

@arieslee
Copy link
Author

3Q,解决了,但是不能通过webuploader以二进制的方式直接上传到七牛,必须自己写程序中转!!!
还有一个问题,我的安卓机,在上传的过程中,进度条一直不动。。
// 文件上传过程中创建进度条实时显示。
uploader.on( 'uploadProgress', function( file, percentage ) {
var box = $('#upload_progress') ,div = box.find('div');
box.show();
div.css( 'width', percentage * 100 + '%' );
});

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants