We developed a workaround for us. Since we work with the file extensions.
On Xiaomi Mi9 (Android 11), ‘path’ of FilePickedCallback is always null.
I wrote details to here(github issue), please check it.
I just started using your plugin today and it’s working great. Is there a way to get the full path & filename for the file that was Exported… that is, after the user may have changed the directory and renamed the file in the picker? Similar to the “path” that NativeFilePicker.PickFile returns?
Thank you!
To my knowledge, this isn’t possible on iOS and, when Storage Access Framework is used (which is when Android 10+), on Android.
Thank you! You saved me a lot of time It worked well on iOS. I didn’t try Android yet but I am sure it will work.
I throw a coin for your coffee, I hope I am not cheap. I might come back once I integrated it on Android
Thank you very much, I appreciate your support
Hello. I ran into a strange problem.
Xiaomi Mi A2 lite Android 10. When choosing a photo, the phone gallery closes, and my application restarts and starts over. I implemented all the fixes from the FAQ section.
Everything works fine on Pixel 3 Android 12. What could be causing this problem?
My code:
Texture2D texture = EditAvatarImage.sprite.texture;
string[] fileTypes = new string[] { "image/*" };
NativeFilePicker.Permission permission = NativeFilePicker.PickFile((path) =>
{
if (path == null)
Debug.Log("Operation cancelled");
else
Debug.Log("Picked file: " + path);
_avatarByte = File.ReadAllBytes(path);
texture.LoadImage(_avatarByte);
}, fileTypes);
EditAvatarImage.sprite = Sprite.Create(
texture,
new Rect(0.0f, 0.0f, texture.width, texture.height),
new Vector2(0.5f, 0.5f), 100.0f);
My guess is RAM shortage. Game uses all of its reserved RAM and restarts as a result. This is not uncommon when using plugins like this on old devices. You can add the plugin to a fresh new project and see if it restarts on Xiaomi, as well.
Hi,
I am trying to use Native File Picker for Android for oculus quest 2 device. Is the Native File Picker applicable for VR? I see only loading symbol inside the device.
I remember someone else having the same issue. I don’t think this plugin works in VR. For VR, you can use SimpleFileBrowser.
Okay Thanks for your quick response.
Hello @yasirkula thanks for your great work!
I just started to use your plugin, but I having some troubles to use correctly the export function, I have a pdf file on my server, I download it to persistentDataPath and use the export function of the plugin to give the user the option to save that file wherever he wants.
What I’m doing right now is just saving that pdf path after downloading it and just calling this:
NativeFilePicker.ExportFile(pdfPath, (success) => debugtext.text += ("File exported: " + success));
That opens a file browser window with a .pdf extension automatically putted in the name field, I put a name to it and click save, it saves the file but with 0 bytes, it seems to be just a .pdf file with no data, when I try to open it using the file explorer it doesn’t open.
There is something that I’m doing wrong by sure
What I’m doing wrong?
Thanks in advance
@Paul-Bones Hi! Could you check Logcat to see if there are any error messages there?
Hi! Does Native File Picker need READ_EXTERNAL_STORAGE permission on Android?
@epernigo Yes, that permission is asked to be safe.
Hi @yasirkula
How can I ask for .fbx files?
I’m trying to use the file picker to open .fbx file on Android phone (BV9000 Pro).
Following your example I did like this:
string fbxFileType = NativeFilePicker.ConvertExtensionToFileType("fbx");
NativeFilePicker.Permission permission = NativeFilePicker.PickFile((path) =>
{
if (path == null)
Debug.Log("Operation cancelled");
else
Debug.Log("Picked file: " + path);
}, new string[] { fbxFileType }
);
Now it shows something like
“Unable to Find Application to Perform this Action”
( I don’t know if exactly like this because it is showing me in Italian )
@antonioritucci336 Your code looks perfectly fine to me, that’s kinda strange. Can you replace fbxFileType with "application/octet-stream"
and see if it prompts the same error? If not, can you log fbxFileType to logcat and see what it outputs?
@yasirkula I tried with “application/octet-stream” I menaged to select .fbx and other octet-stream files
Using this
string fbxFileType = NativeFilePicker.ConvertExtensionToFileType("fbx");
Debug.Log("fbxFileType: " + fbxFileType);
It gives me this log:
I/Unity: fbxFileType:
Guess the problem “Unable to Find Application to Perform this Action” is because it’s using as
fileTypes = new string[] { "" };
This works fine to look for .png files:
string fbxFileType = NativeFilePicker.ConvertExtensionToFileType("fbx");
string pngFileType = NativeFilePicker.ConvertExtensionToFileType("png");
Debug.Log("fbxFileType: " + fbxFileType);
NativeFilePicker.Permission permission = NativeFilePicker.PickFile((path) =>
{
if (path == null)
Debug.Log("Operation cancelled");
else
Debug.Log("Picked file: " + path);
}, new string[] { fbxFileType, pngFileType }
);
With:
new string[] { "application/octet-stream" }
I can select .fbx on Android, how about IOS?
Thank you for your precious work
@antonioritucci336 I thought NativeFilePicker.ConvertExtensionToFileType returned “application/octet-stream” as fallback value but I’ve realized that indeed it returns an empty string. I’d recommend you to set fbxFileType to “application/octet-stream” if it’s null or empty (string.IsNullOrEmpty). Then continue passing that variable to PickFile function. I don’t expect you to hit any obstacles on iOS but if you do, please add fbx to “Window-NativeFilePicker Custom Types” and it should work.
Hello, I am new to iOS development.
Right now I am using this asset to locate the filepath of one or more PNGs stored in the iOS Files app so that I can convert them into Texture2Ds via System.IO.File.ReadAllBytes.
This works perfectly fine in the moment, but I am also trying to create a “recent files” section where the user can access recent PNG selections without going through the file picker interface. When I try to save the filepaths of PNGs locally, and access them via System.IO.File.ReadAllBytes, I always end up with System.IO.FileNotFoundExceptions.
I am accounting for the fact that the app GUID in the app’s local filepath is always changing on iOS by retrieving it at startup.
I am assuming I am running afoul of some restriction that Apple places on filesystem access, so any advice on how to proceed with this “recent files” functionality would be appreciated.