Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

素材管理里的download方法不是很符合sdk一站式的解决. #165

Closed
Smallthing opened this issue Nov 25, 2015 · 3 comments
Closed

Comments

@Smallthing
Copy link

https://mp.weixin.qq.com/wiki/11/5ec27b71532e237cf3dd8451e1a3706b.html

https://mp.weixin.qq.com/wiki/12/473e65b6cf60c5fbb0e02349031bf05c.html

永久素材 无论成功失败返回的都是个json
临时素材 失败了返回个json 成功了只有个header就直接下载了,估计是为了省服务器资源
二进制流里并没有取得到mime

导致我从download方法下载jsapi上传的临时素材(因为是回调过去的,我的系统并不知道他的源文件名),无法知道下载成功/失败,取不到扩展名,这个扩展名在header里有

希望sdk里做一下这个兼容.如果返回的不是json 先看header里有没有content_type来确定扩展名

@overtrue
Copy link
Collaborator

@Smallthing 这个地方确实比较恶心,我再想想怎么改比较合适,如果你有好的建议欢迎提PR

@Smallthing
Copy link
Author

我qq发你的那个 能解决,你看看有什么副作用,没有的话可以考虑加上

@xofers
Copy link

xofers commented Dec 17, 2015

$imgData 为download 下载下来的

$finfo = new \finfo(FILEINFO_MIME_TYPE);
$imgType = strtolower($finfo->buffer($imgData));
$imgType = substr(strrchr($imgType, '/'), 1);
switch ($imgType) {
case 'jpeg':
$imgType = 'jpeg';
break;
case 'jpg':
break;
case 'png':
break;
case 'gif':
break;
default :
$imgType = 'no';
}

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

No branches or pull requests

3 participants