I'm using the image picker plugin for flutter. Whenever I pick an image from the gallery, it is assigned a random name by the plugin, starting with 'image_picker.' How can I get the original name of the image file?
Asked
Active
Viewed 1,842 times
4
-
you cannot - every time a new temporary image is created (at least under android) - https://github.com/flutter/plugins/blob/a5db6e08042b3f6a44e554fc384c76b9e18c7c62/packages/image_picker/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/FileUtils.java#L44 – pskink Jul 07 '20 at 07:32
-
You can change the file name if you are going to store it in firebase storage. Are you trying to do that? – littleironical Jul 07 '20 at 08:05
-
Yes @HardikKumar. But the issue is that I want to store the images by their original name. – Zaeem Jul 07 '20 at 14:19
-
did you solve this? I am getting same issue – Nabin Dhakal Nov 24 '20 at 12:17
-
No I didn't. You'll have to figure out a workaround. – Zaeem Nov 25 '20 at 16:20
-
1I have the same problem with Rest API to which I need to send image files (via Base64) which are name exactly as required by the API. Any ideas? – Łukasz Garczynski Nov 27 '20 at 10:13
1 Answers
2
You can use method as mentioned below. It worked for me
var video = (await _picker.getVideo(source: ImageSource.gallery))!;
var videoName = video.path.split('/').last;

Hemal Moradiya
- 1,715
- 1
- 6
- 26

Durgesh Kudalkar
- 61
- 5