个人随笔
目录
微信打开网站图片长按保存到本地相册找不到的原因和解决办法
2024-02-05 18:23:47

突然发现,IOS可以长按保存图片,安卓有些不可以,怎么回事呢?图片明明正常显示的啊,原来是因为我这边图片文件是一个流,所以img标签配置的src对应url返回的content-type为application/octet-string ,尽然不是image/png这些玩意,所以识别不了是图片,好,那我直接转成base64吧。

  1. function chooseStaticImg(imageUrl) {
  2. let th = this;
  3. this.getImageFileFromUrl(imageUrl, seq_no, function(file) {
  4. let reader = new FileReader();
  5. reader.onloadend = function() {
  6. th.base64 = reader.result;
  7. console.log(th.base64)
  8. };
  9. reader.readAsDataURL(file);
  10. });
  11. }
  12. // 根据路径返回file
  13. function getImageFileFromUrl(url, imageName, callback) {
  14. fetch(url)
  15. .then((res) => {
  16. return res.blob();
  17. })
  18. .then((blob) => {
  19. let imgFile = new File([blob], imageName, { type: typeImg});
  20. callback(imgFile);
  21. });
  22. }
 28

啊!这个可能是世界上最丑的留言输入框功能~


当然,也是最丑的留言列表

有疑问发邮件到 : suibibk@qq.com 侵权立删
Copyright : 个人随笔   备案号 : 粤ICP备18099399号-2