Coder Social home page Coder Social logo

保存图片失败 about image_pickers HOT 21 CLOSED

DaYang816 avatar DaYang816 commented on June 11, 2024
保存图片失败

from image_pickers.

Comments (21)

lisen87 avatar lisen87 commented on June 11, 2024

from image_pickers.

DaYang816 avatar DaYang816 commented on June 11, 2024

一开始我保存成功了 ,去相册图库删除过,就那一次成功了,后面就都是失败 返回null,图片的链接是http的能显示

from image_pickers.

lisen87 avatar lisen87 commented on June 11, 2024

from image_pickers.

DaYang816 avatar DaYang816 commented on June 11, 2024

哦吼 我垃圾桶也清理过,还是失败的, 等待作者发布新的版本,感谢大佬

from image_pickers.

lisen87 avatar lisen87 commented on June 11, 2024

from image_pickers.

DaYang816 avatar DaYang816 commented on June 11, 2024

小米mix3 安卓10

from image_pickers.

lisen87 avatar lisen87 commented on June 11, 2024

from image_pickers.

DaYang816 avatar DaYang816 commented on June 11, 2024

好的 ,再次感谢大佬的插件和回复 👍 :)

from image_pickers.

lisen87 avatar lisen87 commented on June 11, 2024

image_pickers: ^2.0.4+6 版本发布了。还在审核中,稍后可以更新一下试试。或者直接使用github的依赖试试。

from image_pickers.

DaYang816 avatar DaYang816 commented on June 11, 2024

好的,使用后给反馈

from image_pickers.

DaYang816 avatar DaYang816 commented on June 11, 2024
I/Timeline(24564): Timeline: Activity_launch_request time:692186350
W/ActivityThread(24564): handleWindowVisibility: no activity for token android.os.BinderProxy@f5410e5
D/ViewContentFactory(24564): initViewContentFetcherClass
I/ContentCatcher(24564): ViewContentFetcher : ViewContentFetcher
D/ViewContentFactory(24564): createInterceptor took 0ms
2
D/ForceDarkHelper(24564): updateByCheckExcludeList: pkg: com.yongjiang.airobot activity: com.leeson.image_pickers.activitys.PermissionActivity@334f674
E/TAG     (24564): saveImgToGallery: has file
E/TAG     (24564): saveImgToGallery: 复制文件
I/flutter (24564): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (24564): │ 15:15:12.090 (+0:02:26.869550)
I/flutter (24564): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (24564): │ 🐛 null
I/flutter (24564): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/Timeline(24564): Timeline: Activity_launch_request time:692186413
W/ActivityThread(24564): handleWindowVisibility: no activity for token android.os.BinderProxy@6e205b
D/ViewContentFactory(24564): initViewContentFetcherClass
I/ContentCatcher(24564): ViewContentFetcher : ViewContentFetcher
D/ViewContentFactory(24564): createInterceptor took 0ms
2
D/ForceDarkHelper(24564): updateByCheckExcludeList: pkg: com.yongjiang.airobot activity: com.leeson.image_pickers.activitys.PermissionActivity@12885c2
E/TAG     (24564): saveImgToGallery: has file
E/TAG     (24564): saveImgToGallery: 复制文件
I/flutter (24564): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (24564): │ 15:15:12.147 (+0:02:26.925993)
I/flutter (24564): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (24564): │ 🐛 null
I/flutter (24564): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/Toast   (24564): Show toast from OpPackageName:com.yongjiang.airobot, PackageName:com.yongjiang.airobot

作者你好这是最新插件的日志 目前还是发现删除后没有保存成功 返回为null,第一次是成功的然后删除,相册垃圾桶也删除了,再操作保存没有成功
但是可以重复保存的,下面的日志是重新找图然后进行重复保存,相册有2张重复照片操作成功

2
D/ForceDarkHelper(24564): updateByCheckExcludeList: pkg: com.yongjiang.airobot activity: com.leeson.image_pickers.activitys.PermissionActivity@400c7fb
E/TAG     (24564): saveImgToGallery: has file
E/TAG     (24564): saveImgToGallery: 复制文件
I/flutter (24564): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (24564): │ 15:16:42.021 (+0:03:56.799950)
I/flutter (24564): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (24564): │ 🐛 /storage/emulated/0/Pictures/66 (1).png
I/flutter (24564): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/Toast   (24564): Show toast from OpPackageName:com.yongjiang.airobot, PackageName:com.yongjiang.airobot

from image_pickers.

DaYang816 avatar DaYang816 commented on June 11, 2024

我循环2张图片保存,成功后去相册删除了一张,再去重复的保存操作,成功为1张,删除的那张就不会保存了 ,日志返回为null

from image_pickers.

lisen87 avatar lisen87 commented on June 11, 2024

循环保存的代码能提供一下不?我测试一下

from image_pickers.

DaYang816 avatar DaYang816 commented on June 11, 2024

我就写了一个很简单的循环我感觉不是循环的问题,单个估计也这样,我又找了一个小米10的手机,安卓版本13的,也是同样的问题,我怀疑是不是小米特有的,别的机型我测了一下1+T ,华为 都没碰到这个问题

List imgList=[];
//imgList的值是接口给的
  //下载图片
  downImgs() async {
    for (var item in imgList) {
      var path = await ImagePickers.saveImageToGallery(item);
      logD(path);
    }
    toast("保存成功".tr);
  }

from image_pickers.

lisen87 avatar lisen87 commented on June 11, 2024

我测试了,小米10s安卓13没问题,红米 9 没问题,没找到小米10.

你看看能替换一下你本地的这个方法测试一下吗?

public void saveImgToGallery(final String saveUrl, final IFinishListener iFinishListener) {
final String fileName = saveUrl.substring(saveUrl.lastIndexOf("/") + 1);
String dirPath = appPath.getAppImgDirPath();
FileInfo fileInfo = null;

    //判断文件是否下载过
    final File file = new File(dirPath,fileName);
    if (file.exists() && file.length() > 0){
        Log.e("TAG", "saveImgToGallery: has file" );
        fileInfo = new FileInfo();
        fileInfo.setBeforeDownload(true);
        fileInfo.setUri(PictureFileUtils.parUri(context,file));
        fileInfo.setPath(file.getAbsolutePath());
        fileInfo.setSize(file.length());
    }

    if (fileInfo != null && fileInfo.size > 0) {
        Log.e("TAG", "saveImgToGallery: 复制文件" );
        fileInfo = copyImgToPicture(fileInfo.getPath(), System.currentTimeMillis()+fileName);
        notifyGallery(fileInfo.getPath());
        if (iFinishListener != null) {
            iFinishListener.onSuccess(fileInfo);
        }
    } else {
        Log.e("TAG", "saveImgToGallery: 开始下载" );
        download(saveUrl,dirPath , new IDownload() {
            @Override
            public void onDownloadSuccess(String filePath, String fileName) {
                //下载到私有目录成功并复制到公有目录
                FileInfo fileInfo  = copyImgToPicture(filePath, fileName);
                notifyGallery(fileInfo.getPath());
                    /*File originFile = new File(filePath);
                    originFile.delete();*/
                if (iFinishListener != null) {
                    iFinishListener.onSuccess(fileInfo);
                }
            }

            @Override
            public void onDownloadFailed(String errorMsg) {
                if (iFinishListener != null) {
                    iFinishListener.onFailed(errorMsg);
                }
            }
        });
    }



}

from image_pickers.

lisen87 avatar lisen87 commented on June 11, 2024

GitHub我提交了一下代码,或者 依赖一下GitHub的版本测试一下吧。测试机实在不好找

from image_pickers.

DaYang816 avatar DaYang816 commented on June 11, 2024

GitHub的版本 我测一下

from image_pickers.

DaYang816 avatar DaYang816 commented on June 11, 2024

GitHub的版本成功了,测了一下没问题了

from image_pickers.

DaYang816 avatar DaYang816 commented on June 11, 2024

辛苦大佬了,感谢解决问题,: ) 👍

from image_pickers.

lisen87 avatar lisen87 commented on June 11, 2024

互相学习。一会我发版本。说一下原因吧, 第二次存储时,因为图片的名称已经存在了,导致存储失败。而我手边的手机刚好 系统会自动重命名,太巧了。我用Google的模拟器 也是会 自动重命名的,所以一直没有出现问题。

from image_pickers.

DaYang816 avatar DaYang816 commented on June 11, 2024

您这么说我就发现了,,我这边的手机返回的path文件名字是一样的如果是重复文件会(1)这样命名类似window文件重复命名规则。感谢大佬的解释

from image_pickers.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.