Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting Audio File without extensions #487

Closed
roquegoncalves opened this issue Nov 6, 2020 · 23 comments
Closed

Getting Audio File without extensions #487

roquegoncalves opened this issue Nov 6, 2020 · 23 comments
Labels
android Issue applies to Android platform triage Further information is requested

Comments

@roquegoncalves
Copy link

roquegoncalves commented Nov 6, 2020

Describe the bug
I'm using latest version of Flutter 1.20.4 and Android Studio 4.1. Flutter doctor has no issues.
Latest version of FilePicker 2.0.12.

When I try to select a music file from the default android picker choosing the audio folder, I can get the file but it's coming without the extension on the file path.

Issue details

  1. Android
  2. Android 9.0
  3. File type (audio)
  4. Select the default picker from android, click in audio (like in the image below) and choose an audio file.

image

Error Log
D/FilePickerDelegate( 4922): Selected type audio/*
I/FilePickerUtils( 4922): Caching from URI: content://com.android.providers.media.documents/document/audio%3A299529
D/FilePickerUtils( 4922): File loaded and cached at:/data/user/0/com.application/cache/file_picker/(SIC)
D/FilePickerDelegate( 4922): File path:[com.mr.flutter.plugin.filepicker.FileInfo@7a6542d]

Flutter Version details
[✓] Flutter (Channel unknown, 1.20.4, on Mac OS X 10.15.7 19H2, locale en-BR)
• Flutter version 1.20.4 at /Users/roque/Documents/flutter
• Framework revision fba99f6cf9 (8 weeks ago), 2020-09-14 15:32:52 -0700
• Engine revision d1bc06f032
• Dart version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at /Users/roque/Library/Android/sdk
• Platform android-30, build-tools 30.0.2
• ANDROID_HOME = ${HOME}/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.0.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.0.1, Build version 12A7300
• CocoaPods version 1.9.3

[✓] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 1.20.4
• Dart plugin version 2.9.2 (stable)
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] Connected device (1 available)
• Moto Z3 Play (mobile) • 0047758004 • android-arm64 • Android 9 (API 28)

@roquegoncalves roquegoncalves added the new issue An issue that hasn't yet been seen from the maintainer label Nov 6, 2020
@miguelpruivo
Copy link
Owner

@roquegoncalves can you try with file_picker: 2.0.11 and see if it's still happening? Might be a regression introduced on the latest version.

Thank you.

@miguelpruivo miguelpruivo added triage Further information is requested android Issue applies to Android platform and removed new issue An issue that hasn't yet been seen from the maintainer labels Nov 6, 2020
@roquegoncalves
Copy link
Author

@miguelpruivo I tried in the version 2.0.11 and 2.0.10 and got the same result.

@miguelpruivo
Copy link
Owner

@roquegoncalves does that happen with all audio files?

@roquegoncalves
Copy link
Author

roquegoncalves commented Nov 10, 2020

@miguelpruivo This happens with flac, wav, m4a, mp3 and ogg files, but I didn't tried any other format.
I did some tests and the last version that this worked (using que audio selection) was in the version 1.13.3, on version 2.0.0 already stopped working.

@miguelpruivo
Copy link
Owner

@roquegoncalves so the audio selection was working prior to 2.0.0 properly for you?

@roquegoncalves
Copy link
Author

roquegoncalves commented Nov 16, 2020

@miguelpruivo Exactly, on my tests everything works fine prior version 2.0.0

@miguelpruivo
Copy link
Owner

Hi, is this still an issue?

@roquegoncalves
Copy link
Author

Hi, I tested on version 2.1.0 and still doesn't work, but I'm good using the 1.13.3 version for my project.
Thanks!

@Topup3
Copy link

Topup3 commented Dec 10, 2020

Hi, you closed but this issue is not resolved. I got same error. I printed single.path, single.name and paths.first.

These are logs:

D/FilePickerUtils( 8690): File loaded and cached at:/data/user/0/app.test/cache/file_picker/Kozmos.Com
D/FilePickerDelegate( 8690): File path:[com.mr.flutter.plugin.filepicker.FileInfo@77f8f6c]
I/flutter ( 8690): pickedFile.files.single.path: /data/user/0/app.test/cache/file_picker/Kozmos.Com
I/flutter ( 8690): pickedFile.files.single.name: Kozmos.Com
I/flutter ( 8690): pickedFile.paths.first: /data/user/0/app.test/cache/file_picker/Kozmos.Com

Real file name is Kozmos.Com.mp3

Flutter doctor print;

D:\flutter\flutter\bin\flutter.bat doctor --verbose
[√] Flutter (Channel stable, 1.22.4, on Microsoft Windows [Version 10.0.19042.685], locale en-GB)
    • Flutter version 1.22.4 at D:\flutter\flutter
    • Framework revision 1aafb3a8b9 (4 weeks ago), 2020-11-13 09:59:28 -0800
    • Engine revision 2c956a31c0
    • Dart version 2.10.4

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at D:/Android/sdk
    • Platform android-30, build-tools 30.0.2
    • ANDROID_HOME = D:/Android/sdk
    • ANDROID_SDK_ROOT = D:\Android\sdk
    • 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.1.0)
    • Android Studio at C:\Program Files\Android\Android Studio
    X Flutter plugin not installed; this adds Flutter specific functionality.
    X Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] VS Code (version 1.51.1)
    • VS Code at C:\Users\PC\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.17.0

[√] Connected device (1 available)
    • Redmi Note 6 Pro (mobile) • 6209c265 • android-arm64 • Android 9 (API 28)

@miguelpruivo miguelpruivo reopened this Dec 10, 2020
@vkbaloda
Copy link

vkbaloda commented Dec 13, 2020

I'm also having a similar issue but only in OnePlus device (also checked on pixel emulator & Mi Note 7s)

version details:
file_picker: ^2.0.13
flutter: 1.22.2
dart: 2.10.2

how to reproduce the error:

FilePickerResult result = await FilePicker.platform.pickFiles();
result.files.forEach((f) => print("${f.name}\n${f.extension}\n${f.size}\n${f.path}\n${f.runtimeType}"));

the output of above print:

Waka Waka (This Time for Africa) - Shakira 🎵
Waka Waka (This Time for Africa) - Shakira 🎵
5697
/data/user/0/com.test.app/cache/file_picker/Waka Waka (This Time for Africa) - Shakira 🎵
PlatformFile

name of file selected:

Waka Waka (This Time for Africa) - Shakira 🎵.mp3

*just verifying again, when used on other devices it prints the ".mp3" also for name & path; and with the correct extension print

@miguelpruivo
Copy link
Owner

miguelpruivo commented Dec 13, 2020

Hi, I've just tried with both name examples and both seem to work properly on Pixel 2 emulator as posted in screenshot below:
Captura de ecrã 2020-12-13, às 15 45 32

The method to extract the file name is generic and should cover most cases, which can be found here.

Nevertheless, just updated the naming method, let me know if it fixed for you with version 2.1.3.

Let me know if this is still an issue @Topup3 @vkbaloda. Thanks.

@Topup3
Copy link

Topup3 commented Dec 14, 2020

Hi, I tried version 2.1.4, it's not resolved for me @miguelpruivo, same device, same result.

I/flutter (17199): pickedFile.files.single.path: /data/user/0/app.test/cache/file_picker/Kozmos.Com
I/flutter (17199): pickedFile.files.single.name: Kozmos.Com
I/flutter (17199): pickedFile.paths.first: /data/user/0/app.test/cache/file_picker/Kozmos.Com
I/flutter (17199): pickedFile.names.first: Kozmos.Com

@miguelpruivo
Copy link
Owner

@Topup3 would like to help you, but as you can see, mine works properly. Could you please try with a different device so we can figure where the issue is coming from?

@vkbaloda
Copy link

Thanks for helping Miguel

I tried the latest version (2.1..4) and sadly, the problem remains.
The problem is only coming in OnePlus 6 device and with AUDIO files (in my case); it's working on other devices like pixel emulator and Mi Note 7s.

adding screenshots of picker below:

  1. Pixel Emulator
    pixelEmulator
  2. OnePlus 6
    OnePlus6

problem explanation:
When we run FilePickerResult result = await FilePicker.platform.pickFiles(); and select an AUDIO file, the returned Platform file doesn't have extension info with it. This happens only in OnePlus 6 device.

To reproduce it:

  1. Download this song or any other song/audio file
  2. select it using this-> FilePicker.platform.pickFiles(); command on OnePlus device
  3. try printing the selected file name or path result.files.forEach((f) => print("${f.name}\n${f.extension}\n${f.size}\n${f.path}\n${f.runtimeType}")); (It doesn't show the extension of it)

Please tell me if I can help with something✌

@miguelpruivo
Copy link
Owner

Since this is only happening with a very specific device I'm afraid that is because somehow the underlying SDK is modified from the platform OEM ROM.

It won't be easy to debug or even understand what might be causing it.

@Topup3
Copy link

Topup3 commented Dec 14, 2020

Hi @miguelpruivo , version 1.13.3 is working well but after 2.0 not working for me ( for audios for me too. ) I will check again it with emulator and another real device, I will tell you after my tests.

@miguelpruivo
Copy link
Owner

@Topup3 before 2.0.0, the plugin was using a deprecated API and non reliable way to query the file content (such as name) instead of properly using the URI. Probably that was working but there were a lot of other devices that didn’t work that way and since API 30 we can’t actually use it anymore.

Unfortunately there isn’t much else to do there. But let me know if you find a fix.

@vishwajit76
Copy link

FileType.audio not working

@aavgeen
Copy link

aavgeen commented Feb 9, 2021

Mostly, doesn't work on Oneplus phones.

FileType.audio or even FileType.custom with allowedExtensions: ['mp3, 'ogg'] etc doesn't work. Even the mimetype is empty as there is no file extension.

@miguelpruivo
Copy link
Owner

@aavgeen I'm sorry as I don't have those devices. Device specific are hard to debug and most of the times make it quite impossible to fix/handle this kind of issues with ease. Feel free to issue a PR if you find what the problem is.

Thank you.

@miguelpruivo
Copy link
Owner

Closing due to inactivity.

@HugoHeneault
Copy link

Hey guys,

I am also reproducing it on a Redmi mobile and Samsung s7 Edge. I think it is worth reopening...
Also looking on it will tell you if I find something.

@miguelpruivo
Copy link
Owner

@HugoHeneault let me know if you come up with something and I’ll reopen right away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android Issue applies to Android platform triage Further information is requested
Projects
None yet
Development

No branches or pull requests

7 participants