CarnegieTechnologies / gallery_saver

Flutter plugin that saves images and videos to devices gallery
Apache License 2.0
157 stars 328 forks source link

Unhandled Exception: Invalid argument(s): File on path is not an image.` #180

Open ingvilow opened 2 years ago

ingvilow commented 2 years ago

Hi. I would like to know if the issue about saving the image and videos without adding externsions on file is solved? because the images goes without extensions from my API and O get the error:

: [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Invalid argument(s): File on path is not an image.

my code is: 
void _saveNetworkImage() async {
    var inputedStartTime = DateTime.parse(startTimeController.text);
    var mili = inputedStartTime.millisecondsSinceEpoch / 1000;
    var startTime = mili.toInt();
    String fileUrl =
        "https://cameras/874/snapshot/$startTime";
    GallerySaver.saveImage(fileUrl).then((bool success) {
      setState(() {
        print('Image is saved');
      });
    });
lucasvps commented 2 years ago

Same problem here

mark8044 commented 2 years ago

Same problem

ingvilow commented 2 years ago

I can give advice to use image_gallery_saver. This package works as same as that package and doesn't require any file's extensions. I solved my task this way

mafreud commented 1 year ago

GallerySaver accepts only String path of image file saved on device. To save image from internet, first save the image on device and retrieve path. Then, pass the pass to saveFile().

// from https://pub.dev/packages/image_gallery_saver
var appDocDir = await getTemporaryDirectory();
String savePath = appDocDir.path + "/temp.mp4";
await Dio().download("http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4", savePath);
final result = await GallerySaver.saveFile(savePath);

ImageGallerySaver did the same trick to save the image from the internet.