wx.downloadFile下载.png图片 返回.BIN格式的文件 导致保存失败
手机上使用wx.downloadFile下载oss上的.png图片,返回是.bin格式的文件,到时后续用wx.saveImageToPhotosAlbum保存图片失败,报{errMsg: "saveImageToPhotosAlbum:fail invalid file type"},但是在开发工具上可以直接返回png格式图片,可以保存。 如下为用wx.downloadFile请求和返回的结果。 wx.downloadFile({ url: 'https://prod-auops.oss-cn-shenzhen.aliyuncs.com/wxacode/5/gm.png?Expires=4724616620&OSSAccessKeyId=LW6Q1beRi0R3m14r&Signature=S/v7ibcS1c7nP12EvBsLp3sk3j0%3D', success(res) { if (res.statusCode === 200) { console.log(res) wx.saveImageToPhotosAlbum({ filePath: res.tempFilePath, success(res) { console.log(res) wx.showToast({ icon: 'none', title: "图片已保存" }) }, fail(res){ console.log(res) } }) } } }) 返回结果 {tempFilePath: "wxfile://tmp_54d93ed93a853a3a9765337741943c492df65fcd1db83a0a.bin", header: {…}, statusCode: 200, errMsg: "downloadFile:ok"} errMsg: "downloadFile:ok" header: Accept-Ranges: "bytes" Connection: "keep-alive" Content-Disposition: "attachment;filename=gm.png" Content-Length: "103837" Content-MD5: "T4RW3zvQtapK4rYXVczxJA==" Content-Type: "application/octet-stream" Date: "Mon, 14 Oct 2019 01:12:50 GMT" ETag: ""4F8456DF3BD0B5AA4AE2B61755CCF124"" Last-Modified: "Sun, 13 Oct 2019 14:30:55 GMT" Server: "AliyunOSS" X-Android-Received-Millis: "1571015568965" X-Android-Response-Source: "NETWORK 200" X-Android-Selected-Protocol: "http/1.1" X-Android-Sent-Millis: "1571015568954" x-oss-hash-crc64ecma: "13627780087634526589" x-oss-object-type: "Normal" x-oss-request-id: "5DA3CB929ACC073532C38DAE" x-oss-server-time: "2" x-oss-storage-class: "Standard" __proto__: Object statusCode: 200 tempFilePath: "wxfile://tmp_54d93ed93a853a3a9765337741943c492df65fcd1db83a0a.bin" __proto__: Object