Giter Site home page Giter Site logo

gallery_saver's People

Contributors

ailic88 avatar becostopclub avatar bramdekker avatar dvird avatar ened avatar jelenalecic avatar jochendev avatar jonasjuss avatar lecicdjuro avatar letalus avatar m-schmailzl avatar ruichen0101 avatar saad29 avatar sebasbad avatar thehypnoo avatar themisir avatar thomasstoeckert avatar yvbbrjdr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

gallery_saver's Issues

Command CompileSwiftSources failed with a nonzero exit code (in target 'gallery_saver' from project 'Pods')

I am facing this issue with the 'gallery_saver' when I tried to build my Flutter app for iOS. I can run the app on my simulator or local devices for testing purposes. When I try to build a release version for the app, this error pops up at the Archive Build/Analyze stage in the XCode.

Error
`CompileSwiftSources normal armv7 com.apple.xcode.tools.swift.compiler (in target 'gallery_saver' from project 'Pods')
cd /Users/appuser/codeBase/flutter/ios/Pods
export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer
export SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.4.sdk
export TOOLCHAINS="org.swift.30220161213a "
/Library/Developer/Toolchains/swift-3.0.2-RELEASE.xctoolchain/usr/bin/swiftc -incremental -module-name gallery_saver -Onone -enable-batch-mode -enforce-exclusivity=checked @/Users/appuser/Library/Developer/Xcode/DerivedData/Runner-bsbtyadcgnorhndshclbxpflcqxv/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/gallery_saver.build/Objects-normal/armv7/gallery_saver.SwiftFileList -DDEBUG -D COCOAPODS -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.4.sdk -target armv7-apple-ios8.0 -g -module-cache-path /Users/appuser/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -Xfrontend -serialize-debugging-options -enable-testing -index-store-path /Users/appuser/Library/Developer/Xcode/DerivedData/Runner-bsbtyadcgnorhndshclbxpflcqxv/Index/DataStore -swift-version 5 -I /Users/appuser/Library/Developer/Xcode/DerivedData/Runner-bsbtyadcgnorhndshclbxpflcqxv/Build/Products/Debug-iphoneos/gallery_saver -F /Users/appuser/Library/Developer/Xcode/DerivedData/Runner-bsbtyadcgnorhndshclbxpflcqxv/Build/Products/Debug-iphoneos/gallery_saver -F /Users/appuser/codeBase/flutter/ios/Flutter -parse-as-library -c -j4 -output-file-map /Users/appuser/Library/Developer/Xcode/DerivedData/Runner-bsbtyadcgnorhndshclbxpflcqxv/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/gallery_saver.build/Objects-normal/armv7/gallery_saver-OutputFileMap.json -parseable-output -serialize-diagnostics -emit-dependencies -emit-module -emit-module-path /Users/appuser/Library/Developer/Xcode/DerivedData/Runner-bsbtyadcgnorhndshclbxpflcqxv/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/gallery_saver.build/Objects-normal/armv7/gallery_saver.swiftmodule -Xcc -I/Users/appuser/Library/Developer/Xcode/DerivedData/Runner-bsbtyadcgnorhndshclbxpflcqxv/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/gallery_saver.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/appuser/Library/Developer/Xcode/DerivedData/Runner-bsbtyadcgnorhndshclbxpflcqxv/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/gallery_saver.build/gallery_saver-generated-files.hmap -Xcc -I/Users/appuser/Library/Developer/Xcode/DerivedData/Runner-bsbtyadcgnorhndshclbxpflcqxv/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/gallery_saver.build/gallery_saver-own-target-headers.hmap -Xcc -I/Users/appuser/Library/Developer/Xcode/DerivedData/Runner-bsbtyadcgnorhndshclbxpflcqxv/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/gallery_saver.build/gallery_saver-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/appuser/Library/Developer/Xcode/DerivedData/Runner-bsbtyadcgnorhndshclbxpflcqxv/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/gallery_saver.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/appuser/Library/Developer/Xcode/DerivedData/Runner-bsbtyadcgnorhndshclbxpflcqxv/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/gallery_saver.build/gallery_saver-project-headers.hmap -Xcc -I/Users/appuser/Library/Developer/Xcode/DerivedData/Runner-bsbtyadcgnorhndshclbxpflcqxv/Build/Products/Debug-iphoneos/gallery_saver/include -Xcc -I/Users/appuser/Library/Developer/Xcode/DerivedData/Runner-bsbtyadcgnorhndshclbxpflcqxv/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/gallery_saver.build/DerivedSources-normal/armv7 -Xcc -I/Users/appuser/Library/Developer/Xcode/DerivedData/Runner-bsbtyadcgnorhndshclbxpflcqxv/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/gallery_saver.build/DerivedSources/armv7 -Xcc -I/Users/appuser/Library/Developer/Xcode/DerivedData/Runner-bsbtyadcgnorhndshclbxpflcqxv/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/gallery_saver.build/DerivedSources -Xcc -DPOD_CONFIGURATION_DEBUG=1 -Xcc -DDEBUG=1 -Xcc -DCOCOAPODS=1 -emit-objc-header -emit-objc-header-path /Users/appuser/Library/Developer/Xcode/DerivedData/Runner-bsbtyadcgnorhndshclbxpflcqxv/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/gallery_saver.build/Objects-normal/armv7/gallery_saver-Swift.h -import-underlying-module -Xcc -ivfsoverlay -Xcc /Users/appuser/Library/Developer/Xcode/DerivedData/Runner-bsbtyadcgnorhndshclbxpflcqxv/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/gallery_saver.build/unextended-module-overlay.yaml -Xcc -working-directory/Users/appuser/codeBase/flutter/ios/Pods

:0: error: unknown argument: '-enable-batch-mode'
:0: error: unknown argument: '-enforce-exclusivity=checked'
:0: error: unknown argument: '-index-store-path'
:0: error: unknown argument: '-swift-version'
Command CompileSwiftSources failed with a nonzero exit code`

Multiple images download

Hi guys,

Thanks for the work on this plugin.
When I use it to download a single image it works. But when I use it while looping over a set of image urls.
I have only tried it on Android

refAlbum.pictures.forEach((picture) {
  GallerySaver.saveImage(picture.url).then((bool success) {
    print('success');
  });
});
W/System  (10078): A resource failed to call close.
E/AndroidRuntime( 9028): FATAL EXCEPTION: main
E/AndroidRuntime( 9028): Process: xxxxxxxxxxx, PID: 9028
E/AndroidRuntime( 9028): kotlin.KotlinNullPointerException
E/AndroidRuntime( 9028): 	at carnegietechnologies.gallery_saver.GallerySaver.finishWithSuccess(GallerySaver.kt:112)
E/AndroidRuntime( 9028): 	at carnegietechnologies.gallery_saver.GallerySaver.access$finishWithSuccess(GallerySaver.kt:15)
E/AndroidRuntime( 9028): 	at carnegietechnologies.gallery_saver.GallerySaver$saveImage$1.invokeSuspend(GallerySaver.kt:91)
E/AndroidRuntime( 9028): 	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
E/AndroidRuntime( 9028): 	at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:238)
E/AndroidRuntime( 9028): 	at android.os.Handler.handleCallback(Handler.java:873)
E/AndroidRuntime( 9028): 	at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 9028): 	at android.os.Looper.loop(Looper.java:193)
E/AndroidRuntime( 9028): 	at android.app.ActivityThread.main(ActivityThread.java:6669)
E/AndroidRuntime( 9028): 	at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 9028): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/AndroidRuntime( 9028): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
W/System  ( 9028): A resource failed to call close.
I/Process ( 9028): Sending signal. PID: 9028 SIG: 9
Lost connection to device.
Exited (sigterm)

How can I get this to work with multiple images?

Crash when combined with Firebase Background Messaging

The plugin crashes when combined with firebase cloud messaging.
If my app receives a background notification, the gallery_saver plugin calls registrant.activity() when there is no activity.

i fixed it by changing the GallerySaverPlugin.kt method "registerWith" to the following:

fun registerWith(registrar: Registrar) { val channel = MethodChannel(registrar.messenger(), "gallery_saver") if (registrar==null || registrar.activity()==null) { return; } val gallerySaver = GallerySaver(registrar.activity()) registrar.addRequestPermissionsResultListener(gallerySaver) val instance = GallerySaverPlugin( gallerySaver) channel.setMethodCallHandler(instance) }

would be nice to add this to the the next version.

Rename Image

How to change the name of the image ???

GallerySaver.saveImage(recordedImage.path, albumName: "Manager").then((path){};

Invalid argument(s): File on path is not an image.

Hey guys. There is a problem with URLs that have query params such as facebook images firebase storage images, etc.
For image on this link:
(https://scontent.flju2-1.fna.fbcdn.net/v/t1.0-9/71515447_2410538489194566_4191628866734784512_n.jpg?_nc_cat=1&_nc_oc=AQlh0ua3e1wQE5YN8CLL1ebDQSVhN9U-xa1k23i8dgUqMQX5apqyNxsYsWYJx65dbBM&_nc_ht=scontent.flju2-1.fna&oh=c2036dc3070d4c1fcd6b17e73c9ab6ad&oe=5E3176F8)
library spews out Unhandled Exception: Invalid argument(s): File on path is not an image.

I didn't go too deep into debugging, but I'd say that
bool isImage(String path) => imageFormats.contains(extension(path).toLowerCase());
returns false, because extension(path) call doesn't handle extensions okay, when there are query params involved. :)

Android - App crashes when I try to save an image

I don't know what kind of information is useful at this time to fix this, please, let me know.

app/build.gradle
android.compileSdkVersion 28
android.defaultConfig.inSdkVersion 24
android.defaultConfig.targetSdkVersion 28

Permission granted in
android.permission.WRITE_EXTERNAL_STORAGE

E/AndroidRuntime(  849): android.database.sqlite.SQLiteException: table thumbnails has no column named relative_path (code 1 SQLITE_ERROR): , while compiling: INSERT INTO thumbnails (height,image_id,kind,_data,width,relative_path) VALUES (?,?,?,?,?,?)
E/AndroidRuntime(  849): 	at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:184)
E/AndroidRuntime(  849): 	at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:140)
E/AndroidRuntime(  849): 	at android.content.ContentProviderProxy.insert(ContentProviderNative.java:549)
E/AndroidRuntime(  849): 	at android.content.ContentResolver.insert(ContentResolver.java:2045)
E/AndroidRuntime(  849): 	at android.content.ContentResolver.insert(ContentResolver.java:2007)
E/AndroidRuntime(  849): 	at carnegietechnologies.gallery_saver.FileUtils.storeThumbnail(FileUtils.kt:165)
E/AndroidRuntime(  849): 	at carnegietechnologies.gallery_saver.FileUtils.insertImage(FileUtils.kt:84)
E/AndroidRuntime(  849): 	at carnegietechnologies.gallery_saver.GallerySaver$saveMediaFile$1$success$1.invokeSuspend(GallerySaver.kt:69)
E/AndroidRuntime(  849): 	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
E/AndroidRuntime(  849): 	at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:238)
E/AndroidRuntime(  849): 	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:594)
E/AndroidRuntime(  849): 	at kotlinx.coroutines.scheduling.CoroutineScheduler.access$runSafely(CoroutineScheduler.kt:60)
E/AndroidRuntime(  849): 	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:742)
I/Process (  849): Sending signal. PID: 849 SIG: 9
Lost connection to device.

Get the path of downloaded image

Hi guys,

I want to set wallpaper by using an image which I downloaded with gallery_saver library. But I need a path (location in device) of downloaded image to set wallpaper.
How can I get it?

Thanks.

GallerySaver.saveVideo does not run in a WorkManager task

Hi, I am trying to do the GallerySaver.saveVideo operation in a WorkManager Task. However it doesn't work, and the task ends with a failure. I don't know where else to ask for help.

void callbackDispatcher() {
  Workmanager.executeTask((task, inputData) async {
    String inPath = inputData['videoPath'];
    print('awaiting gallery saver');
    var res = await GallerySaver.saveVideo(inPath);
    print('awaited gallery saver');
    return true;
  });
}

The first log is printed ('awaiting gallery saver'), but not the second one, and the task ends with an error:
I/WM-WorkerWrapper(15020): Worker result FAILURE for Work [ id=113bb45f-4600-4787-9b72-29595f670c52, tags={ be.tramckrijte.workmanager.BackgroundWorker } ]

Other async calls work fine:
var rc = await flutterFFmpeg.execute(ffmpegCmd);

This encoding step takes about a minute to complete but it works properly in place of the GallerySaver call above, so I think the general structure of my task is ok.

I'll appreciate any help.

Registration in other isolate

Hi, first thanks for this plugin!

I have a small problem, when the plugin has to be registered not from UI, but from other isolate, it crashes.
The problem is that I use https://github.com/vrtdev/flutter_workmanager for background updates and the task is stared in other isolate. Where all plugins are registered as they will work in isolation. This registration process is in background and has no activity, which crashes this plugin and respectively all plugins. The result is running Isolate code with no registered plugins.
I have overridden local lib version with the code bellow and it saves my problem, because this plugin is used in UI only. But it affects only my PC and all other devs in my team has to do the same fix.
Is it possible to push a new version with try/catch ?

Thanks in advance!


 companion object {
        @JvmStatic
        fun registerWith(registrar: Registrar) {
            try {
                val channel = MethodChannel(registrar.messenger(),
                        "gallery_saver")
                val gallerySaver = GallerySaver(registrar.activity())
                registrar.addRequestPermissionsResultListener(gallerySaver)
                val instance = GallerySaverPlugin(
                        gallerySaver)
                channel.setMethodCallHandler(instance)
            } catch (e: Exception) {
                android.util.Log.e("gallery_saver", "error on registration", e)
            }
        }
    } 

On iOS is all good

Future doesn't complete when permission asked

Library example used. It happens on Android, didn't try on IOS.

// main.dart
void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  double textSize = 20;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        home: Scaffold(
          body: Container(
            color: Colors.white,
            child: Column(
              children: <Widget>[
                Flexible(
                  flex: 1,
                  child: Container(
                    child: SizedBox.expand(
                      child: RaisedButton(
                        color: Colors.blue,
                        onPressed: _saveNetworkImage,
                        child: Text('Save image from network',
                            style:
                            TextStyle(fontSize: textSize, color: Colors.white)),
                      ),
                    ),
                  ),
                ),
                Flexible(
                  child: Container(
                      child: SizedBox.expand(
                        child: RaisedButton(
                          color: Colors.white,
                          onPressed: _saveNetworkVideo,
                          child: Text('Save video from network',
                              style: TextStyle(
                                  fontSize: textSize, color: Colors.blueGrey)),
                        ),
                      )),
                  flex: 1,
                )
              ],
            ),
          ),
        ));
  }
  void _saveNetworkVideo() async {
    String path =
        'https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_1mb.mp4';
    GallerySaver.saveVideo(path).then((bool success) {
      setState(() {
        print('Video is saved');
      });
    });
  }

  void _saveNetworkImage() async {
    String path =
        'https://image.shutterstock.com/image-photo/montreal-canada-july-11-2019-600w-1450023539.jpg';
    GallerySaver.saveImage(path).then((bool success) {
      setState(() {
        print('Image is saved');
      });
    });
  }
}

WRITE_EXTERNAL_STORAGE permission added to AndroidManifest.xml

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

steps

1. tap the button (save image)
2. app asks the permission and allow it
3. image saved to disk but future isn't completed
4. then try again to tap the button
5. future completes successfully

console outputs/logs

I/flutter (27326): File size:53182
I/flutter (27326): /data/user/0/com.gallery.gallery_saver_test/cache/montreal-canada-july-11-2019-600w-1450023539.jpg
I/flutter (27326): https://image.shutterstock.com/image-photo/montreal-canada-july-11-2019-600w-1450023539.jpg
I/flutter (27326): File size:53182
I/flutter (27326): /data/user/0/com.gallery.gallery_saver_test/cache/montreal-canada-july-11-2019-600w-1450023539.jpg
I/flutter (27326): Image is saved

versions

gallery_saver: ^1.0.7
flutter: last stable
device: samsung s8
android: 9

twice save expection

java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.net.Uri.getLastPathSegment()' on a null object reference
    at android.content.ContentUris.parseId(ContentUris.java:85)
    at carnegietechnologies.gallery_saver.FileUtils.insertImage(FileUtils.kt:79)
    at carnegietechnologies.gallery_saver.GallerySaver$saveMediaFile$1$success$1.invokeSuspend(GallerySaver.kt:69)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:238)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:594)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.access$runSafely(CoroutineScheduler.kt:60)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:742)

Fileutils line 67
imageUri = contentResolver.insert(imageUri, values)
This method will return null for two saves

Does not compile on android in app with `compileSdkVersion 30`

Due to additional nullability annotations added to the android framework in API level 30 this plugin does not compile when included in an app targeting compileSdkVersion 30.

This can be fixed with a few small changes in FileUtils.kt to provide default values for potential nulls in some log statements.

To replicate update the compileSdkVersion to 30 in the example project and attempt to build.

Android 10 scoped storage compatibility

Using version 1.0.7 of gallery_saver.

Behavior on an Android 10 device, when using a 'targetSdkVersion' of 29:

The albumName parameter is ignored for both images and videos. This is because your implementation of it is not compliant with Android 10's scoped storage. As per this link, you should be using MediaColumns.RELATIVE_PATH in order to indicate the target folder/album.

It seems that the behavior on Android 10 is to ignore the DATA column that you currently use to indicate the desired path, so images and videos end up within the default locations 'Pictures' and 'Movies'.

Behavior on an Android 10 device, when using a 'targetSdkVersion' below 29:

The 'albumName' parameter works as intended. Saving videos is working as intended. Saving an image will result in a crash at the point of trying to save its thumbnail, with the stack trace below. The crash occurs after successfully saving the image itself, which can found in the expected folder.

W/MediaStore(25518): Failed to obtain thumbnail for content://media/external/images/media/622
W/MediaStore(25518): java.io.FileNotFoundException: open failed: ENOENT (No such file or directory)
W/MediaStore(25518): 	at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:149)
W/MediaStore(25518): 	at android.content.ContentProviderProxy.openTypedAssetFile(ContentProviderNative.java:705)
W/MediaStore(25518): 	at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1687)
W/MediaStore(25518): 	at android.content.ContentResolver.openTypedAssetFile(ContentResolver.java:1592)
W/MediaStore(25518): 	at android.content.ContentResolver.lambda$loadThumbnail$0(ContentResolver.java:3590)
W/MediaStore(25518): 	at android.content.-$$Lambda$ContentResolver$7ILY1SWNxC2xhk-fQUG6tAXW9Ik.call(Unknown Source:10)
W/MediaStore(25518): 	at android.graphics.ImageDecoder$CallableSource.createImageDecoder(ImageDecoder.java:550)
W/MediaStore(25518): 	at android.graphics.ImageDecoder.decodeBitmapImpl(ImageDecoder.java:1847)
W/MediaStore(25518): 	at android.graphics.ImageDecoder.decodeBitmap(ImageDecoder.java:1840)
W/MediaStore(25518): 	at android.content.ContentResolver.loadThumbnail(ContentResolver.java:3589)
W/MediaStore(25518): 	at android.content.ContentResolver.loadThumbnail(ContentResolver.java:3573)
W/MediaStore(25518): 	at android.provider.MediaStore$InternalThumbnails.getThumbnail(MediaStore.java:1553)
W/MediaStore(25518): 	at android.provider.MediaStore$Images$Thumbnails.getThumbnail(MediaStore.java:1912)
W/MediaStore(25518): 	at a.a.a.a(Unknown Source:178)

'gallery_saver/gallery_saver-Swift.h' file not found

I added gallery_saver to my project, and got an error as below when building iOS app.

** BUILD FAILED **
Xcode's output:

=== BUILD TARGET sqflite OF PROJECT Pods WITH CONFIGURATION Debug ===
/Users/Ranyzhang/WorkSpace/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/gallery_saver-1.0.1/ios/Classes/GallerySaverPlugin.m:2:9: fatal error: 'gallery_saver/gallery_saver-Swift.h' file not found

#import <gallery_saver/gallery_saver-Swift.h>
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.`

Completely Crashing the App on Android

Hi,

Thank you for the great plugin, I am having a small issue on Android.

Device: Samsung Galaxy SM A520F
Running in Debug mode
Error on Device 'App Name has stopped working`
Plugin version gallery_saver: ^1.0.6

Checks on Device

  • I have checked the device storage, and it has enough storage to save the image (a couple of GB free)
  • I have added the required android permissions etc

Code

ImagePicker.pickImage(source: ImageSource.camera).then(
              (File recordedImage) async {
                if (recordedImage != null && recordedImage.path != null) {
                  try {
                    GallerySaver.saveImage(recordedImage.path); // If I remove this code, everything works fine however the image is not saved on device
                  } catch (e) {
                    print(e);
                  }
                }
              },
            );

Flutter Doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.9.1+hotfix.5, on Mac OS X 10.15 19A602, locale en-GB)
 
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.0)
[✓] Android Studio (version 3.5)
[✓] VS Code (version 1.39.1)
[✓] Connected device (2 available)

• No issues found!

Error Messge in Android Studio

D/ViewRootImpl@82f00f9[MainActivity](28189): mHardwareRenderer.destroy()#1
D/ViewRootImpl@82f00f9[MainActivity](28189): Relayout returned: oldFrame=[0,0][1080,1920] newFrame=[0,0][1080,1920] result=0x1 surface={isValid=false 0} surfaceGenerationChanged=false
D/SurfaceView(28189): Relayout returned: oldFrame=[0,0][1080,1920] newFrame=[0,0][1080,1920] result=0x7 surface={Surface(name=null)/@0x6d5b3b5 isValid=true 496777930240}
D/mali_winsys(28189): EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000,  [1080x1920]-format:1
D/ViewRootImpl@82f00f9[MainActivity](28189): Relayout returned: oldFrame=[0,0][1080,1920] newFrame=[0,0][1080,1920] result=0x7 surface={isValid=true 496087858176} surfaceGenerationChanged=true
D/ViewRootImpl@82f00f9[MainActivity](28189): mHardwareRenderer.initialize() mSurface={isValid=true 496087858176} hwInitialized=true
D/mali_winsys(28189): EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000,  [1080x1920]-format:1
D/ViewRootImpl@82f00f9[MainActivity](28189): MSG_WINDOW_FOCUS_CHANGED 1
D/ViewRootImpl@82f00f9[MainActivity](28189): mHardwareRenderer.initializeIfNeeded()#2 mSurface={isValid=true 496087858176}
V/InputMethodManager(28189): Starting input: tba=android.view.inputmethod.EditorInfo@e01b523 nm : co.uk.gallagherltd.gard ic=null
I/InputMethodManager(28189): [IMM] startInputInner - mService.startInputOrWindowGainedFocus
D/InputTransport(28189): Input channel constructed: fd=94
I/ExifInterface_JNI(28189): Raw image not detected
I/ExifInterface(28189): innerIfdHint: 1
I/ExifInterface(28189): innerIfdHint: 3
W/ExifInterface(28189): Skip the tag entry since tag number is not defined: 2
I/ExifInterface(28189): innerIfdHint: 2
I/ExifInterface_JNI(28189): Raw image not detected
I/art     (28189): Starting a blocking GC Alloc
I/art     (28189): Starting a blocking GC Alloc
I/art     (28189): Alloc sticky concurrent mark sweep GC freed 2175(166KB) AllocSpace objects, 0(0B) LOS objects, 11% free, 84MB/96MB, paused 258us total 8.544ms
I/art     (28189): Starting a blocking GC Alloc
I/art     (28189): Alloc partial concurrent mark sweep GC freed 301(9KB) AllocSpace objects, 3(73MB) LOS objects, 40% free, 11MB/19MB, paused 246us total 31.361ms
I/art     (28189): Waiting for a blocking GC Alloc
I/art     (28189): WaitForGcToComplete blocked for 11.159ms for cause Alloc
I/art     (28189): Starting a blocking GC Alloc
I/art     (28189): Starting a blocking GC Alloc
I/art     (28189): Starting a blocking GC Alloc
I/art     (28189): Alloc partial concurrent mark sweep GC freed 8(200B) AllocSpace objects, 0(0B) LOS objects, 18% free, 72MB/88MB, paused 235us total 14.360ms
I/art     (28189): Starting a blocking GC Alloc
I/art     (28189): Alloc concurrent mark sweep GC freed 47(17KB) AllocSpace objects, 0(0B) LOS objects, 18% free, 72MB/88MB, paused 256us total 39.811ms
I/art     (28189): Forcing collection of SoftReferences for 60MB allocation
I/art     (28189): Starting a blocking GC Alloc
I/art     (28189): Alloc concurrent mark sweep GC freed 42(1872B) AllocSpace objects, 0(0B) LOS objects, 18% free, 72MB/88MB, paused 386us total 39.266ms
W/art     (28189): Throwing OutOfMemoryError "Failed to allocate a 63701004 byte allocation with 16777216 free bytes and 55MB until OOM"
I/art     (28189): Starting a blocking GC Alloc
I/art     (28189): Starting a blocking GC Alloc
I/art     (28189): Starting a blocking GC Alloc
I/art     (28189): Alloc partial concurrent mark sweep GC freed 6(144B) AllocSpace objects, 0(0B) LOS objects, 18% free, 72MB/88MB, paused 303us total 14.218ms
I/art     (28189): Starting a blocking GC Alloc
I/art     (28189): Alloc concurrent mark sweep GC freed 3(72B) AllocSpace objects, 0(0B) LOS objects, 18% free, 72MB/88MB, paused 417us total 40.005ms
I/art     (28189): Forcing collection of SoftReferences for 60MB allocation
I/art     (28189): Starting a blocking GC Alloc
I/art     (28189): Alloc concurrent mark sweep GC freed 3(72B) AllocSpace objects, 0(0B) LOS objects, 18% free, 72MB/88MB, paused 280us total 40.051ms
W/art     (28189): Throwing OutOfMemoryError "Failed to allocate a 63701004 byte allocation with 16777216 free bytes and 55MB until OOM"
E/AndroidRuntime(28189): FATAL EXCEPTION: DefaultDispatcher-worker-1
E/AndroidRuntime(28189): Process: co.uk.gallagherltd.gard, PID: 28189
E/AndroidRuntime(28189): java.lang.OutOfMemoryError: Failed to allocate a 63701004 byte allocation with 16777216 free bytes and 55MB until OOM
E/AndroidRuntime(28189): 	at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
E/AndroidRuntime(28189): 	at android.graphics.Bitmap.nativeCreate(Native Method)
E/AndroidRuntime(28189): 	at android.graphics.Bitmap.createBitmap(Bitmap.java:977)
E/AndroidRuntime(28189): 	at android.graphics.Bitmap.createBitmap(Bitmap.java:948)
E/AndroidRuntime(28189): 	at android.graphics.Bitmap.createBitmap(Bitmap.java:879)
E/AndroidRuntime(28189): 	at carnegietechnologies.gallery_saver.FileUtils.getRotatedBytesIfNecessary(FileUtils.kt:119)
E/AndroidRuntime(28189): 	at carnegietechnologies.gallery_saver.FileUtils.insertImage(FileUtils.kt:49)
E/AndroidRuntime(28189): 	at carnegietechnologies.gallery_saver.GallerySaver$saveMediaFile$1$success$1.invokeSuspend(GallerySaver.kt:69)
E/AndroidRuntime(28189): 	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
E/AndroidRuntime(28189): 	at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:238)
E/AndroidRuntime(28189): 	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:594)
E/AndroidRuntime(28189): 	at kotlinx.coroutines.scheduling.CoroutineScheduler.access$runSafely(CoroutineScheduler.kt:60)
E/AndroidRuntime(28189): 	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:742)
D/ViewRootImpl@82f00f9[MainActivity](28189): MSG_WINDOW_FOCUS_CHANGED 0
D/SurfaceView(28189): Relayout returned: oldFrame=[0,0][1080,1920] newFrame=[0,0][1080,1920] result=0x5 surface={Surface(name=null)/@0x6d5b3b5 isValid=false 0}
D/ViewRootImpl@82f00f9[MainActivity](28189): mHardwareRenderer.destroy()#1
D/ViewRootImpl@82f00f9[MainActivity](28189): Relayout returned: oldFrame=[0,0][1080,1920] newFrame=[0,0][1080,1920] result=0x5 surface={isValid=false 0} surfaceGenerationChanged=true
D/ViewRootImpl@82f00f9[MainActivity](28189): mHardwareRenderer.destroy()#4
D/ViewRootImpl@82f00f9[MainActivity](28189): dispatchDetachedFromWindow
D/InputTransport(28189): Input channel destroyed: fd=84

Great package, but it won't save images from a path that doesn't include a file extension.

Really great package with a concise API. There's a big problem, however. This package won't download any image from a package that doesn't end with a supported file extension. The problem? URLs from many different places don't have the file extension. That error makes this package unusable for many, many use cases, including firebase.

You should allow the package user to specify their own request future. This would mean that you could still control the file extension that the package downloads, but also allow the user to request from a URL that doesn't contain an extension if necessary. Cheers!

File on path is not a video

Not Working with Firebase MP4 file. It gives me error.

Video URL

E/flutter ( 9221): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: Invalid argument(s): File on path is not a video.
E/flutter ( 9221): #0      GallerySaver.saveVideo (package:gallery_saver/gallery_saver.dart:27:7)
E/flutter ( 9221): #1      _OptionSelectionState.saveToLocale (package:pixz_app/ui/widgets/options_view.dart:618:22)
E/flutter ( 9221): <asynchronous suspension>
E/flutter ( 9221): #2      _OptionSelectionState.currentUserPost.<anonymous closure> (package:pixz_app/ui/widgets/options_view.dart:193:15)
E/flutter ( 9221): #3      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
E/flutter ( 9221): #4      TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:486:11)
E/flutter ( 9221): #5      BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:264:5)
E/flutter ( 9221): #6      BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:236:7)
E/flutter ( 9221): #7      GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
E/flutter ( 9221): #8      GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:222:20)
E/flutter ( 9221): #9      GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
E/flutter ( 9221): #10     GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
E/flutter ( 9221): #11     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
E/flutter ( 9221): #12     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
E/flutter ( 9221): #13     _rootRunUnary (dart:async/zone.dart:1138:13)
E/flutter ( 9221): #14     _CustomZone.runUnary (dart:async/zone.dart:1031:19)
E/flutter ( 9221): #15     _CustomZone.runUnaryGuarded (dart:async/zone.dart:933:7)
E/flutter ( 9221): #16     _invoke1 (dart:ui/hooks.dart:273:10)
E/flutter ( 9221): #17     _dispatchPointerDataPacket (dart:ui/hooks.dart:182:5)
E/flutter ( 9221): 

gallery_saver: ^2.0.1 and workmanager: ^0.2.3 don't work together.

I am using gallery_saver: ^2.0.1 and workmanager: ^0.2.3 packages but they don't work together.
This error occurs when i add pubspec.yaml to gallery_saver: ^2.0.1.

Error:
Tried to automatically register plugins with FlutterEngine (io.flutter.embedding.engine.FlutterEngine@7eaf22b) but could not find and invoke the GeneratedPluginRegistrant.

Optionally don't delete file after saving to gallery

Add the option to not automatically delete the temporary file, or return the path of the saved file.
(For example when the file should be further used, e.g. upload to a server).

The 'not deleting'-.way seems to be easier to implement and not braking user space of the stored gallery file.

Add the optional argument "deleteFile" in 'lib/gallery_saver.dart' on line 21:
static Future<bool> saveVideo(String path, {String albumName, bool deleteFile = false}) async {

and 44:
static Future<bool> saveImage(String path, {String albumName, bool deleteFile = false}) async {

and change the if clauses on line 37 and 61:
if (tempFile != null && deleteFile) {

should fix this issue.

Crash on Android

GallerySaver.saveImage(imgUrl, albumName: "vaguePic").then((bool success) {

      Toast.show("saved success!", context, duration: 3, gravity: Toast.BOTTOM);

   

  });

Android Version :10

Can i save network image using this plugin?

When i pass a network image url to GallerySaver.saveImage method,the app crashed and throw an exception:java.io.FileNotFoundException.
Can you support network image save?
thank you.

How to get saved image path name?

File image = await ImagePicker.pickImage(source: ImageSource.camera);
GallerySaver.saveImage("${image.path}", albumName: 'my_image_folder').then((bool result) {
                  if (result) {
                    log('image saved!');
                  }
                  else
                    log('saving image job has been failed');
                });

Hello there! I'm currently working with above code base.
i wonder that how to get image path that saved in my_image_folder.
i can get only boolean flag that result of GallerySaver.saveImage()

is there a way to get the saved image path string?

correct way to judge if a url is response image.

bool isImage(String path) =>   imageFormats.contains(extension(path).toLowerCase());

I think we should not using url's extension to judge if it's a image url, in fact we should use content-Type,
eg:

Content-Type: image/jpeg

saveVideo() not saving videos into albums

I'm using the following function to save a video:

await GallerySaver.saveVideo("${temporaryPath.path}/output.mp4",
        albumName: "TimeLapseApp");

To my knowledge, this should save to the TimeLapseApp album (note that this is a new album). The video is being saved into the Movies album (Movies folder on Android).

image

Allow saving to custom sub folder and naming image

Hi,

Thanks for the plugin , however it would be better if you were able to use it to create a folder in the directory that you save it into.

i.e. on my phone it saves directly to pictures and it would be good if it could either create or have a function to create a sub directory that it uses for saving i.e. pictures/MyApp

Also being able to name the saved image would be good,

App crashes with exception java.io.FileNotFoundException: open failed: ENOENT

When the image is passed to the plugin it crashes the application. If there is a FileNotFoundException then the plugin should throw an Exception to flutter.

Here are the Logs

I/flutter ( 7398): APPLOGS : saveFileToLocal /data/user/0/com.package.name/cache/image_cropper_1583319540032.jpg
W/MediaStore( 7398): Failed to obtain thumbnail for content://media/external/images/media/1757
W/MediaStore( 7398): java.io.FileNotFoundException: open failed: ENOENT (No such file or directory)
W/MediaStore( 7398): 	at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:149)
W/MediaStore( 7398): 	at android.content.ContentProviderProxy.openTypedAssetFile(ContentProviderNative.java:705)
W/MediaStore( 7398): 	at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1694)
W/MediaStore( 7398): 	at android.content.ContentResolver.openTypedAssetFile(ContentResolver.java:1599)
W/MediaStore( 7398): 	at android.content.ContentResolver.lambda$loadThumbnail$0(ContentResolver.java:3623)
W/MediaStore( 7398): 	at android.content.-$$Lambda$ContentResolver$7ILY1SWNxC2xhk-fQUG6tAXW9Ik.call(Unknown Source:10)
W/MediaStore( 7398): 	at android.graphics.ImageDecoder$CallableSource.createImageDecoder(ImageDecoder.java:550)
W/MediaStore( 7398): 	at android.graphics.ImageDecoder.decodeBitmapImpl(ImageDecoder.java:1847)
W/MediaStore( 7398): 	at android.graphics.ImageDecoder.decodeBitmap(ImageDecoder.java:1840)
W/MediaStore( 7398): 	at android.content.ContentResolver.loadThumbnail(ContentResolver.java:3622)
W/MediaStore( 7398): 	at android.content.ContentResolver.loadThumbnail(ContentResolver.java:3606)
W/MediaStore( 7398): 	at android.provider.MediaStore$InternalThumbnails.getThumbnail(MediaStore.java:1579)
W/MediaStore( 7398): 	at android.provider.MediaStore$Images$Thumbnails.getThumbnail(MediaStore.java:1938)
W/MediaStore( 7398): 	at carnegietechnologies.gallery_saver.FileUtils.insertImage(FileUtils.kt:80)
W/MediaStore( 7398): 	at carnegietechnologies.gallery_saver.GallerySaver$saveMediaFile$1$success$1.invokeSuspend(GallerySaver.kt:69)
W/MediaStore( 7398): 	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
W/MediaStore( 7398): 	at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:238)
W/MediaStore( 7398): 	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:594)
W/MediaStore( 7398): 	at kotlinx.coroutines.scheduling.CoroutineScheduler.access$runSafely(CoroutineScheduler.kt:60)
W/MediaStore( 7398): 	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:742)
E/AndroidRuntime( 7398): FATAL EXCEPTION: main
E/AndroidRuntime( 7398): Process: com.package.name, PID: 7398
E/AndroidRuntime( 7398): java.lang.IllegalStateException: miniThumb must not be null
E/AndroidRuntime( 7398): 	at carnegietechnologies.gallery_saver.FileUtils.insertImage(FileUtils.kt:83)
E/AndroidRuntime( 7398): 	at carnegietechnologies.gallery_saver.GallerySaver$saveMediaFile$1$success$1.invokeSuspend(GallerySaver.kt:69)
E/AndroidRuntime( 7398): 	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
E/AndroidRuntime( 7398): 	at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:238)
E/AndroidRuntime( 7398): 	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:594)
E/AndroidRuntime( 7398): 	at kotlinx.coroutines.scheduling.CoroutineScheduler.access$runSafely(CoroutineScheduler.kt:60)
E/AndroidRuntime( 7398): 	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:742)
I/System.out( 7398): (HTTPLog)-Static: isSBSettingEnabled false
I/System.out( 7398): (HTTPLog)-Static: isSBSettingEnabled false
I/Process ( 7398): Sending signal. PID: 7398 SIG: 9

Here the save function

  static Future<Null> saveFileToLocal(File file) async {
    appLogs("saveFileToLocal ${file.path}");

    try {
      //Save file local storage as well.
      final result = await GallerySaver.saveImage(
        file.path,
        albumName:"App Name",
      );
      appLogs("saveFileToLocal result $result");
    } catch (e, s) {
      appLogs("  saveFileToLocal ERROR $e\n$s");
    }

    return null;
  }

device info
SAMSUNG G973F • RZ8M309W8JJ • android-arm64 • Android 10 (API 29)

flutter doctor

[✓] Flutter (Channel beta, v1.14.6, on Mac OS X 10.15.3 19D76, locale en-GB)
 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 3.5)
[!] VS Code (version 1.42.1)
    ✗ Flutter extension not installed; install from
      https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected device (3 available)

! Doctor found issues in 1 category.

App crashes on Android when saving an image that has been saved already

The app crashes completely, and I can not catch the exception, which is a problem.

It could make sense to allow for an optional overwrite. At the very least I should be able to catch an exception that states that an image with the given name already exists in the given album.

I get the following error output:
E/AndroidRuntime(16029): FATAL EXCEPTION: DefaultDispatcher-worker-1 E/AndroidRuntime(16029): Process: com.willow.willowframe.dev, PID: 16029 E/AndroidRuntime(16029): java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.net.Uri.getLastPathSegment()' on a null object reference E/AndroidRuntime(16029): at android.content.ContentUris.parseId(ContentUris.java:88) E/AndroidRuntime(16029): at carnegietechnologies.gallery_saver.FileUtils.insertImage(FileUtils.kt:79) E/AndroidRuntime(16029): at carnegietechnologies.gallery_saver.GallerySaver$saveMediaFile$1$success$1.invokeSuspend(GallerySaver.kt:69) E/AndroidRuntime(16029): at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) E/AndroidRuntime(16029): at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:238) E/AndroidRuntime(16029): at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:594) E/AndroidRuntime(16029): at kotlinx.coroutines.scheduling.CoroutineScheduler.access$runSafely(CoroutineScheduler.kt:60) E/AndroidRuntime(16029): at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:742) I/Process (16029): Sending signal. PID: 16029 SIG: 9 Lost connection to device.

After delete files by file.delete(), could not saveImage()

I use GallerySaver.saveImage to save image to gallery. I will delete the image in gallery when it has been existed.

But after I do await file.delete(), GallerySaver.saveImage() will not throw exception, where the image is saved failed (It could not be found in gallery).

My code:

print(url);
var filename = url.split('/').last;
var androidGallery = await getAndroidGalleryPath();
var galleryFile = File('$androidGallery/$filename');
if (await galleryFile.exists()) {
  print('delete');
  await galleryFile.delete();
}
GallerySaver.saveImage(url, albumName: APP_NAME).then((ok) async {
  print(ok ? 'success' : 'failed: ??');
  var ex = await galleryFile.exists();
  print(ex);
}).catchError((e) {
  var msg = e?.toString() ?? '';
  if (msg == '') {
    msg = '??';
  }
  print('failed: $msg');
});
I/flutter ( 3672): https://flutter.dev/assets/flutter-lockup-c13da9c9303e26b8d5fc208d2a1fa20c1ef47eb021ecadf27046dea04c0cebf6.png
I/flutter ( 3672): https://flutter.dev/assets/flutter-lockup-c13da9c9303e26b8d5fc208d2a1fa20c1ef47eb021ecadf27046dea04c0cebf6.png
I/flutter ( 3672): File size:21232
I/flutter ( 3672): /data/user/0/com.aoihosizora.xxx/cache/flutter-lockup-c13da9c9303e26b8d5fc208d2a1fa20c1ef47eb021ecadf27046dea04c0cebf6.png
I/flutter ( 3672): success
I/flutter ( 3672): true

I/flutter ( 3672): https://flutter.dev/assets/flutter-lockup-c13da9c9303e26b8d5fc208d2a1fa20c1ef47eb021ecadf27046dea04c0cebf6.png
I/flutter ( 3672): delete // <<< delete existed file
I/flutter ( 3672): https://flutter.dev/assets/flutter-lockup-c13da9c9303e26b8d5fc208d2a1fa20c1ef47eb021ecadf27046dea04c0cebf6.png
I/flutter ( 3672): File size:21232
I/flutter ( 3672): /data/user/0/com.aoihosizora.xxx/cache/flutter-lockup-c13da9c9303e26b8d5fc208d2a1fa20c1ef47eb021ecadf27046dea04c0cebf6.png
I/flutter ( 3672): success // save success
I/flutter ( 3672): false // after download, file is not existed???

I/flutter ( 3672): https://flutter.dev/assets/flutter-lockup-c13da9c9303e26b8d5fc208d2a1fa20c1ef47eb021ecadf27046dea04c0cebf6.png
// -> not delete???
I/flutter ( 3672): https://flutter.dev/assets/flutter-lockup-c13da9c9303e26b8d5fc208d2a1fa20c1ef47eb021ecadf27046dea04c0cebf6.png
I/flutter ( 3672): File size:21232
I/flutter ( 3672): /data/user/0/com.aoihosizora.xxx/cache/flutter-lockup-c13da9c9303e26b8d5fc208d2a1fa20c1ef47eb021ecadf27046dea04c0cebf6.png
I/flutter ( 3672): success // save success again
I/flutter ( 3672): false // but file is still not existed

Download image with requested headers

Hey, i found your package and it's really helpful, but I need to download an image, which is protected by a token, so I need to be able to send headers alongside my request, and I did not see any options like this in the plugin. If there is one, could you help me ? If there is not, I think it could be a nice add.

Android App crashing with while saving the image path on gallery_saver

I have facing the below error while am saving the images on android using this plugin,

E/AndroidRuntime( 8194): FATAL EXCEPTION: DefaultDispatcher-worker-1
E/AndroidRuntime( 8194): Process: com.ventechsolutions.myFHB, PID: 8194
E/AndroidRuntime( 8194): java.io.FileNotFoundException: 19c879d4-6353-48da-bccf-6f93cbf4126a.jpg: open failed: ENOENT (No such file or directory)
E/AndroidRuntime( 8194): 	at libcore.io.IoBridge.open(IoBridge.java:496)
E/AndroidRuntime( 8194): 	at java.io.FileInputStream.<init>(FileInputStream.java:159)
E/AndroidRuntime( 8194): 	at carnegietechnologies.gallery_saver.FileUtils.getBytesFromFile(FileUtils.kt:216)
E/AndroidRuntime( 8194): 	at carnegietechnologies.gallery_saver.FileUtils.insertImage(FileUtils.kt:47)
E/AndroidRuntime( 8194): 	at carnegietechnologies.gallery_saver.GallerySaver$saveMediaFile$1$success$1.invokeSuspend(GallerySaver.kt:69)
E/AndroidRuntime( 8194): 	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
E/AndroidRuntime( 8194): 	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
E/AndroidRuntime( 8194): 	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
E/AndroidRuntime( 8194): 	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
E/AndroidRuntime( 8194): 	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
E/AndroidRuntime( 8194): 	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
E/AndroidRuntime( 8194): Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
E/AndroidRuntime( 8194): 	at libcore.io.Linux.open(Native Method)
E/AndroidRuntime( 8194): 	at libcore.io.ForwardingOs.open(ForwardingOs.java:167)
E/AndroidRuntime( 8194): 	at libcore.io.BlockGuardOs.open(BlockGuardOs.java:252)
E/AndroidRuntime( 8194): 	at libcore.io.ForwardingOs.open(ForwardingOs.java:167)
E/AndroidRuntime( 8194): 	at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:7499)
E/AndroidRuntime( 8194): 	at libcore.io.IoBridge.open(IoBridge.java:482)
E/AndroidRuntime( 8194): 	... 10 more
I/Process ( 8194): Sending signal. PID: 8194 SIG: 9
Lost connection to device.
Exited (sigterm)

here I have attached my flutter doctor summary,

[√] Flutter (Channel stable, 1.20.3, on Microsoft Windows [Version
10.0.18363.959], locale en-IN)
• Flutter version 1.20.3 at C:\flutter_config\flutter
• Framework revision 216dee60c0 (7 days ago), 2020-09-01 12:24:47 -0700
• Engine revision d1bc06f032
• Dart version 2.9.2

[√] Android toolchain - develop for Android devices (Android SDK version
30.0.0)
• Android SDK at C:\Users\vmohan\AppData\Local\Android\sdk
• Platform android-30, build-tools 30.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build
1.8.0_242-release-1644-b01)
• All Android licenses accepted.

[√] Android Studio (version 4.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 48.1.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build
1.8.0_242-release-1644-b01)

[√] VS Code (version 1.48.2)
• VS Code at C:\Users\vmohan\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.14.0

[√] Connected device (1 available)
• moto g 7 (mobile) • ZF6224BH73 • android-arm64 • Android 10 (API 29)

• No issues found!

Gallery_Saver_Swift.h not found

I tried to add this package for the purpose of saving network image into my gallery for both iOS and android but the moment i run my application its giving me this error providing in this line .
Version i am using : gallery_saver: ^1.0.7

Crash on android when save same url image the second time.

Hi, there.

Thanks for provide this life save library.

I've faced an issue when save same url image the second time.

Logs shows:

2020-04-03 09:51:08.036 E: Error inserting _data=/storage/emulated/0/Pictures/share_picture.png parent=6 _display_name=share_picture.png format=14347 title=share_picture.png bucket_id=-1617409521 _size=415694 date_added=1585878668 datetaken=1585878668033 date_modified=1585878659 mime_type=image/png media_type=1 bucket_display_name=Pictures
    android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: files._data (code 2067 SQLITE_CONSTRAINT_UNIQUE)
        at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native Method)
        at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:796)
        at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:788)
        at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:86)
        at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1564)
        at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1433)
        at com.android.providers.media.MediaProvider.insertFile(MediaProvider.java:2433)
        at com.android.providers.media.MediaProvider.insertInternal(MediaProvider.java:2628)
        at com.android.providers.media.MediaProvider.insert(MediaProvider.java:1940)
        at android.content.ContentProvider$Transport.insert(ContentProvider.java:266)
        at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:152)
        at android.os.Binder.execTransact(Binder.java:733)

It seems same url will use same filename then same primary key in SQLite, which will throw SQLITE_CONSTRAINT_UNIQUE1.

If we can handle this at libary level, bellow are some improvements:

1. provide filename parameter when save image or video
2. throw error back to developer instead of crash app

Thanks for any opinions.

FileUtils.kt perhaps has a little bug

Thanks for the pretty tools.

When saving video to album(only for android, not tested under iOS yet), I found the output video is so large,and file size is 8M*n (n is 1,2,3...).
I check the source code and found a little bug in:
gallery_saver/android/src/main/kotlin/carnegietechnologies/gallery_saver/FileUtils.kt
function: insertVideo
line:264
codes:

while (inputStream.read(buffer) != EOF) {
    outputStream.write(buffer)
}

The buffer length is BUFFER_SIZE*n (1024 * 1024 * 8 * n),and outputStream write the gross data with whole buffer.
I think it should write the pure buffer instead and the codes will be:

var readLen = inputStream.read(buffer)
while (readLen != EOF) {
    outputStream.write(buffer, 0, readLen)
    readLen = inputStream.read(buffer)
}

And it works well by these codes.

Thanks for your great project gallery_saver again!

Save bytes to album instead of file

It would be great if the API was able to take a Uint8List instead of a path. Sometimes, the image is available in RAM but it seems silly to have to write it to temporary storage just to pass it to the plugin.

Can't save file on Android and app crashed

I have below code:

try {
      var image = await ImagePicker.pickImage(source: ImageSource.camera);
      var path = GallerySaver.saveImage(image.path);
      developer.log('path $path');
    } catch (err) {
      developer.log('failed to take photo', error: err);
    }

and app crashed on GallerySaver.saveImage(image.path);. The error I got is:

E/AndroidRuntime(17754): FATAL EXCEPTION: main
E/AndroidRuntime(17754): Process: com.example.rent_exp_app, PID: 17754
E/AndroidRuntime(17754): android.database.sqlite.SQLiteException: table thumbnails has no column named relative_path (code 1 SQLITE_ERROR): , while compiling: INSERT INTO thumbnails (height,image_id,kind,_data,width,relative_path) VALUES (?,?,?,?,?,?)
E/AndroidRuntime(17754): 	at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:185)
E/AndroidRuntime(17754): 	at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:141)
E/AndroidRuntime(17754): 	at android.content.ContentProviderProxy.insert(ContentProviderNative.java:549)
E/AndroidRuntime(17754): 	at android.content.ContentResolver.insert(ContentResolver.java:2083)
E/AndroidRuntime(17754): 	at android.content.ContentResolver.insert(ContentResolver.java:2045)

It seems that it failed to save thumbnails to SQLite database.

GallerySaver.saveImage crashes on Android 11.0

Devices: Pixel 4 XL, Pixel 5 XL
Device Type: Virtual & Physical
Android Version: 11.0 API 30

An exception and crash occurs upon calling GallerySaver.saveImage however, the image DOES get saved to the gallery successfully. The app simply crashes at this point. Tested also on Android 10.0 on both devices and the crash does not happen.

E/AndroidRuntime(20767): java.lang.IllegalArgumentException: Invalid column NULL
E/AndroidRuntime(20767): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:172)
E/AndroidRuntime(20767): at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:153)
E/AndroidRuntime(20767): at android.content.ContentProviderProxy.openAssetFile(ContentProviderNative.java:704)
E/AndroidRuntime(20767): at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1816)
E/AndroidRuntime(20767): at android.content.ContentResolver.openOutputStream(ContentResolver.java:1518)
E/AndroidRuntime(20767): at android.content.ContentResolver.openOutputStream(ContentResolver.java:1494)
E/AndroidRuntime(20767): at carnegietechnologies.gallery_saver.FileUtils.storeThumbnail(FileUtils.kt:172)
E/AndroidRuntime(20767): at carnegietechnologies.gallery_saver.FileUtils.insertImage(FileUtils.kt:84)
E/AndroidRuntime(20767): at carnegietechnologies.gallery_saver.GallerySaver$saveMediaFile$1$success$1.invokeSuspend(GallerySaver.kt:69)
E/AndroidRuntime(20767): at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
E/AndroidRuntime(20767): at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:238)
E/AndroidRuntime(20767): at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:594)
E/AndroidRuntime(20767): at kotlinx.coroutines.scheduling.CoroutineScheduler.access$runSafely(CoroutineScheduler.kt:60)
E/AndroidRuntime(20767): at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:742)

test on ios for download network video?

 void _saveNetworkVideo() async {
    String path =
        'https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_1mb.mp4';
    GallerySaver.saveVideo(path).then((bool success) {
      setState(() {
        print('Video is saved');
      });
    });
  }

these code is not work.
only work for local video file

Fetching Saved Image

it's possible to fetch saved image from picture direcotry ?

I have console result like this, I dont know location path to fetch saved image with this plugin. image gallery saver

It's my code to save image. ``` void _testSaveImage() async { String path = "${Urls.BASE_API_IMAGE}/berita/${widget.gambarBerita}"; GallerySaver.saveImage(path).then((bool success) { print('Success add image $path'); }).catchError((onError) { print('Error add image $path'); }); } ```

Can't Install in pubspec.yaml

I get this error while installing this plugin onmy pubspec.yaml.

e: C:\flutter\flutter\.pub-cache\hosted\pub.dartlang.org\gallery_saver-1.0.4\android\src\main\kotlin\carnegietechnologies\gallery_saver\GallerySaver.kt: (65, 17): 'launch(CoroutineContext = ..., CoroutineStart = ..., suspend CoroutineScope.() -> Unit): Job' is only available since Kotlin 1.3 and cannot be used in Kotlin 1.2
e: C:\flutter\flutter\.pub-cache\hosted\pub.dartlang.org\gallery_saver-1.0.4\android\src\main\kotlin\carnegietechnologies\gallery_saver\GallerySaver.kt: (66, 27): 'async(CoroutineContext = ..., CoroutineStart = ..., suspend CoroutineScope.() -> T): Deferred<T>' is only available since Kotlin 1.3 and cannot be used in Kotlin 1.2
e: C:\flutter\flutter\.pub-cache\hosted\pub.dartlang.org\gallery_saver-1.0.4\android\src\main\kotlin\carnegietechnologies\gallery_saver\GallerySaver.kt: (69, 21): 'await(): T' is only available since Kotlin 1.3 and cannot be used in Kotlin 1.2
e: C:\flutter\flutter\.pub-cache\hosted\pub.dartlang.org\gallery_saver-1.0.4\android\src\main\kotlin\carnegietechnologies\gallery_saver\GallerySaver.kt: (86, 17): 'launch(CoroutineContext = ..., CoroutineStart = ..., suspend CoroutineScope.() -> Unit): Job' is only available since Kotlin 1.3 and cannot be used in Kotlin 1.2
e: C:\flutter\flutter\.pub-cache\hosted\pub.dartlang.org\gallery_saver-1.0.4\android\src\main\kotlin\carnegietechnologies\gallery_saver\GallerySaver.kt: (87, 27): 'async(CoroutineContext = ..., CoroutineStart = ..., suspend CoroutineScope.() -> T): Deferred<T>' is only available since Kotlin 1.3 and cannot be used in Kotlin 1.2
e: C:\flutter\flutter\.pub-cache\hosted\pub.dartlang.org\gallery_saver-1.0.4\android\src\main\kotlin\carnegietechnologies\gallery_saver\GallerySaver.kt: (90, 21): 'await(): T' is only available since Kotlin 1.3 and cannot be used in Kotlin 1.2

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':gallery_saver:compileDebugKotlin'.
> Compilation error. See log for more details

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 28s
Gradle task assembleDebug failed with exit code 1

I'm mistake Something ?

v2.0 cannot save network image any more

The readme instructs this

void _saveNetworkImage() async {
    String path =
        'https://image.shutterstock.com/image-photo/montreal-canada-july-11-2019-600w-1450023539.jpg';
    GallerySaver.saveImage(path).then((bool success) {
      setState(() {
        print('Image is saved');
      });
    });
  }

But once you do that, you'll get

Invalid argument(s): File on path is not an image.

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.