hpoul / file_picker_writable

Flutter plugin to choose files which can be read, referenced and written back at a later time.
https://pub.dev/packages/file_picker_writable
MIT License
17 stars 13 forks source link

How to get the chosen file path on createFile #25

Closed S-Man42 closed 3 years ago

S-Man42 commented 3 years ago

Hi,

I use the lib for having a save dialog. I use it like this:

    final fileInfo = await FilePickerWritable().openFileForCreate(
      fileName: fileName,
      writer: (file) async {
        await file.writeAsBytes(data.buffer.asUint8List());
        fileX = file;
      },
    );

    filePath = fileInfo.identifier;

Afterwards I want to get the chosen path. I am trying with fileInfo.identifier, but this gives only a content uri, not the path (like content://com.android.externalstorage.documents/document/primary%3ADownload%2Fmy_file_name.png, the user chose.

Is there a way to return the chosen directory or convert the content uri into it?

hpoul commented 3 years ago

No, because there is no such thing. The "file" is saved in a content provider, not in the file system. https://developer.android.com/reference/android/content/Intent#ACTION_CREATE_DOCUMENT

You wouldn't be able to do anything with the "path" anyway, because every app on android (and iOS) is sandboxed and has a different file system view.