nativescript-community / ui-document-picker

A NativeScript plugin that allows you to select files from the device.
https://nativescript-community.github.io/ui-document-picker/
Apache License 2.0
10 stars 8 forks source link

Example of extensions to be passed? mimetypes or just suffixes? #2

Closed t1amat9409 closed 2 years ago

t1amat9409 commented 3 years ago

Just a quick question.

Do I use mimetypes: eg. ["application/msword"] OR use it like this ['.doc', '.docx']?

farfromrefug commented 3 years ago

@t1amat9409 sorry did not have the time to make a doc yet

const result = await openFilePicker({
                //@ts-ignore
                extensions: global.isIOS ? [kUTTypeData, kUTTypeContent, kUTTypeItem] : ['*/*'],
                multipleSelection: false,
                pickerMode: 0
            });

Something like that so:

t1amat9409 commented 3 years ago

@farfromrefug ah, thanks man... Will try it out

t1amat9409 commented 3 years ago

@farfromrefug I think ["pdf", "doc"] works well with this, instead of ["application/msword"]

farfromrefug commented 3 years ago

@t1amat9409 you mean on android?

t1amat9409 commented 3 years ago

@farfromrefug my bad, I noticed after a while that all file are greyed out

alexist commented 3 years ago

The extensions filter is working only with one extension ["pdf"] or ["png"], but not with multiple extensions. Android API seems to have changed, and you need something like :

      intent.putExtra(Intent.EXTRA_MIME_TYPES, acceptTypes);
alexist commented 3 years ago

I made a PR https://github.com/nativescript-community/ui-document-picker/pull/3 to fix the issue. It would be nice if you can review it, and merge this fix.

alexist commented 3 years ago

version 1.1.4 fix the issue.

This sample code work on ios and android. In android, you have to specify extension, android will find application mimetype related to the extension provided :

    const options: FilePickerOptions = {
        extensions       : isIOS ? [kUTTypeJPEG, kUTTypePDF] : ['jpeg', 'pdf'],
        multipleSelection: false
    };
t1amat9409 commented 3 years ago

@alexist Awesome

farfromrefug commented 2 years ago

@xpalacincreditoh Please stop spamming this github repo! If you have question github is not the place. You should use Nativescript discord. Github is only for issue reporting. Also in the future please add details, and you can also add a few nice words like please or thanks ...

xpalacincreditoh commented 2 years ago

@xpalacincreditoh Please stop spamming this github repo! If you have question github is not the place. You should use Nativescript discord. Github is only for issue reporting. Also in the future please add details, and you can also add a few nice words like please or thanks ...

Good morning,

I will try to query the errors this plugin gives me in NativeScript Discord. The question was very similar to others that were before mine.

Thanks @farfromrefug