ko2ic / image_downloader

Flutter plugin that downloads images and movies on the Internet and saves to Photo Library on iOS or specified directory on Android.
https://pub.dartlang.org/packages/image_downloader#-readme-tab-
MIT License
92 stars 115 forks source link

can't download from remoteUri #77

Open gaoyong06 opened 4 years ago

gaoyong06 commented 4 years ago

I tested with an Android phone, the Android version is 5.0.2, and I save the picture with the following log, but I can't save it

`

static Future saveNetworkImageToPhoto(String url) async {
print("Run saveNetworkImageToPhoto"); try { // Saved with this method. var imageId = await ImageDownloader.downloadImage(url,destination: AndroidDestinationType.custom(directory: 'qzone')).catchError((error) {

    if (error is PlatformException) {

      var path = "";
      if (error.code == "404") {
        print("saveNetworkImageToPhoto:Not Found Error.");
      } else if (error.code == "unsupported_file") {
        print("saveNetworkImageToPhoto:UnSupported FIle Error.");
        path = error.details["unsupported_file_path"];
      }

      print("saveNetworkImageToPhoto:path: $path");
    }
  });

  print(" imageId = $imageId");

  if (imageId == null) {
    return null;
  }

  // Below is a method of obtaining saved image information.
  var fileName = await ImageDownloader.findName(imageId);
  var path = await ImageDownloader.findPath(imageId);
  var size = await ImageDownloader.findByteSize(imageId);
  var mimeType = await ImageDownloader.findMimeType(imageId);

  print(" path = $path");

  return path; 
} on PlatformException catch (error) {
  print(error);
}

}

`

D/image_downloader(14823): RequestResult(id=521, remoteUri=https://pic.qqhot.com/2020/05/22/YSTl1bBb.jpg, localUri=null, mediaType=null, totalSize=-1, title=, description=) D/image_downloader(14823): 0 D/image_downloader(14823): RequestResult(id=522, remoteUri=https://pic.qqhot.com/2020/05/22/3f78e713ecc6d13e1f28c31afa4cd91a.jpg, localUri=null, mediaType=null, totalSize=-1, title=, description=) D/image_downloader(14823): 0 D/image_downloader(14823): RequestResult(id=522, remoteUri=https://pic.qqhot.com/2020/05/22/3f78e713ecc6d13e1f28c31afa4cd91a.jpg, localUri=null, mediaType=null, totalSize=-1, title=, description=) D/image_downloader(14823): 0 D/image_downloader(14823): RequestResult(id=521, remoteUri=https://pic.qqhot.com/2020/05/22/YSTl1bBb.jpg, localUri=null, mediaType=null, totalSize=-1, title=, description=) D/image_downloader(14823): 0

moaabid commented 3 years ago

Facing similar issue on Android 10 Is there any solution for it