Comments (14)
No, the path
and targetPath
of flutter_image_compress
is provided by the caller, who should ensure permission for the directory.
from flutter_image_compress.
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.
close by #41
from flutter_image_compress.
@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.
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.
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.
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.
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.
Then post the log here and I will try to help you solve this problem.
from flutter_image_compress.
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.
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.
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.
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.
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)
- [Bug report] By using the compressAndGetFile method with the parameter quality:100, the images lose quality. HOT 1
- [Feature request] Return XFile or Path instead of Uint8List for compressions
- [Windows Support]
- [Bug report] Not existing file returned but no error when fed a video instead of an image file
- Support for Linux and Windows platform HOT 4
- [Bug report] Update js package to the latest version HOT 5
- Should it be cropping and changing ratio?
- Images compress by size HOT 1
- 是否有添加鸿蒙平台的打算呢 HOT 4
- [Bug report] call FlutterImageCompress.compressWithList on web get Unimplemented error HOT 7
- [Bug report] Run FlutterImageCompress.compressWithList on flutter web get the exaptation: "Expected a value of type 'Function', but got one of type 'Null'"
- [Add privacy manifest file for iOS] HOT 5
- Bump compileSdk version of Android plugins to latest stable (34)
- Migration to js_interop for WASM Compatibility HOT 2
- [How to use] Conflict Between SDWebImageWebPCoder and flutter_image_compress During iOS Deployment
- [Bug report] Compress do not respect aspect ratio
- [iOS] Crash on CompressFileHandler HOT 1
- Error: UnimplementedError UnsupportedFlutterImageCompress.compressWithFile HOT 2
- [How to use] Web deployment: Uncaught UnimplementedError HOT 1
- [Bug report] Can't compress in a isolate HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter_image_compress.