I want to pick an audio file in Flutter
. I use file_picker
package to pick an audio file. After picking it, I want to upload the file to AWS Storage
, but the file in the path of the picked file does not exist. I check it by the following code snippet:
FilePickerResult? pickedAudioResult = await FilePicker.platform
.pickFiles(type: FileType.any, withData: true);
if (pickedAudioResult == null) return;
PlatformFile pickedFile = pickedAudio.files.single;
print('Does file exist? ${await File(pickedFile.path!).exists()}');
print('File name: ${pickedFile.name}');
print('File extension: ${pickedFile.extension}');
print('File path: ${pickedFile.path}');
print('File size: ${pickedFile.size}');
And the log output is:
Does file exist? false
File name: best ringtones - most romantic 2018.mp3
File extension: mp3
File path: /storage/emulated/0/Android/data/com.salamgram.salamgram/files/Ringtones/best ringtones - most romantic 2018.mp3
File size: 0
I am confused by its strange behavior as it gives some info but doesn't give other.
So how can I get the chosen file as a File
object?