Giter Club home page Giter Club logo

Comments (14)

CaiJingLong avatar CaiJingLong commented on June 27, 2024 1

No, the path and targetPath of flutter_image_compress is provided by the caller, who should ensure permission for the directory.

https://github.com/OpenFlutter/flutter_image_compress/blob/8d8a49dd38c70122f47e055731a5a06b815f0705/lib/flutter_image_compress.dart#L91-L98

from flutter_image_compress.

CaiJingLong avatar CaiJingLong commented on June 27, 2024

As given in the information: Path must not be null.
You have to make sure that the incoming path is not empty in your code.

In image_picker, if you exit without selecting a image, the result is null, so if you use file?.path to get a path, the path is null. Then passing this value to the native will cause problems.

I will deal with this situation in the code, but you also need to make sure the params is not null.

from flutter_image_compress.

CaiJingLong avatar CaiJingLong commented on June 27, 2024

close by #41

from flutter_image_compress.

tudor07 avatar tudor07 commented on June 27, 2024

@CaiJingLong Can you please re-open this issue ? Sorry, but I disagree with this behaviour of quickly closing issues based on your personal assumptions.

I don't pass null to this plugin and I don't exit image_picker without selecting an image. I send valid data and it fails. I don't know what the exception is because I took a look at the code and there is an catch(Exception ) {result(null)} line which doesn't log the exception.

from flutter_image_compress.

CaiJingLong avatar CaiJingLong commented on June 27, 2024

Sorry, I didn't mean to close the issue base assumptions.
I modified some code to handle the case where the input parameter is null from the dart.

If you still have problems using this library, please paste the log here.
The Android section can use ADB logcat to view native logs.

from flutter_image_compress.

tudor07 avatar tudor07 commented on June 27, 2024

Thanks. The issue with pasting the logs is that I think the library crashes on native side, but the exception is swallowed here: https://github.com/OpenFlutter/flutter_image_compress/blob/f18bd08f3cfd923f101eb817d82f6d024ef17021/android/src/main/kotlin/com/example/flutterimagecompress/CompressFileHandler.kt#L50

I think if the exception would be logged we would be able to see it.

from flutter_image_compress.

CaiJingLong avatar CaiJingLong commented on June 27, 2024

This part of the code is because an exception occurred during the native layer compression, and I did not throw the error that occurred here into the dart.

I will modify this part of the code to output this part of the log, and provide a git ref, which you can reference and paste exceptions here.

from flutter_image_compress.

CaiJingLong avatar CaiJingLong commented on June 27, 2024

Please edit your pubspec.yaml.

dependencies:
  flutter_image_compress:
    git:
      url: https://github.com/OpenFlutter/flutter_image_compress.git
      ref: 8d8a49dd38c70122f47e055731a5a06b815f0705

And add code :

FlutterImageCompress.showNativeLog = true;

from flutter_image_compress.

CaiJingLong avatar CaiJingLong commented on June 27, 2024

Then post the log here and I will try to help you solve this problem.

from flutter_image_compress.

tudor07 avatar tudor07 commented on June 27, 2024

Yes, now I can get the logs. Looks like it crashes because of storage permission.

2019-04-17 16:53:26.500 11826-13419/{my_app}} W/System.err: java.io.FileNotFoundException: /storage/emulated/0/DCIM/Camera/20190414_210950.jpg (Permission denied)
2019-04-17 16:53:26.500 11826-13419/{my_app}} W/System.err:     at java.io.FileOutputStream.open0(Native Method)
2019-04-17 16:53:26.500 11826-13419/{my_app}} W/System.err:     at java.io.FileOutputStream.open(FileOutputStream.java:308)
2019-04-17 16:53:26.500 11826-13419/{my_app}} W/System.err:     at java.io.FileOutputStream.<init>(FileOutputStream.java:238)
2019-04-17 16:53:26.500 11826-13419/{my_app}} W/System.err:     at java.io.FileOutputStream.<init>(FileOutputStream.java:180)
2019-04-17 16:53:26.500 11826-13419/{my_app}} W/System.err:     at com.example.flutterimagecompress.CompressFileHandler$handleGetFile$1.run(CompressFileHandler.kt:46)
2019-04-17 16:53:26.500 11826-13419/{my_app}} W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
2019-04-17 16:53:26.500 11826-13419/{my_app}} W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
2019-04-17 16:53:26.500 11826-13419/{my_app}} W/System.err:     at java.lang.Thread.run(Thread.java:764)
2019-04-17 16:53:26.511 11826-11948/{my_app}} I/flutter: Another exception was thrown: NoSuchMethodError: The getter 'path' was called on null.

from flutter_image_compress.

tudor07 avatar tudor07 commented on June 27, 2024

It's strange, why does it need storage permission ? For example flutter_native_image (another library for compression) works without storage permission.

from flutter_image_compress.

tudor07 avatar tudor07 commented on June 27, 2024

Looks like this library tries to write to Camera folder while the other library writes to Context.getExternalCacheDir() which is a directory owned by the app.

from flutter_image_compress.

tudor07 avatar tudor07 commented on June 27, 2024

Now I understand. Yes, I think it's a good idea for this to be configurable.
Maybe report the error somehow back to Dart instead of swallowing it.
Thanks a lot for the help, you can close this issue.

from flutter_image_compress.

CaiJingLong avatar CaiJingLong commented on June 27, 2024

In fact, I added the same question to Readme long ago.

https://github.com/OpenFlutter/flutter_image_compress#troubleshooting

from flutter_image_compress.

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.