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

Error: TypeError: params.extensions.map is not a function when openFilePicker #15

Closed xpalacincreditoh closed 2 years ago

xpalacincreditoh commented 2 years ago

When call openFilePicker console return: Error: TypeError: params.extensions.map is not a function

My SelectModal.vue:

openPicker(item) {
                switch (item.key) {
                    case 'photo':
                        this.mediaService.showCameraPicker().then((files) => {
                            item.files = files;
                            this.$modal.close(item);
                        });
                        break;
                    case 'gallery':
                        this.mediaService.showGalleryPicker().then((files) => {
                            item.files = files;
                            this.$modal.close(item);
                        });
                        break;
                    case 'file':
                        this.mediaService.showFilePicker().then((files) => {
                            item.files = files;
                            this.$modal.close(item);
                        });
                        break;
                    default:
                        this.$modal.close(item);
                        break;
                }
            },

My MediaService.js:

import { openFilePicker } from '@nativescript-community/ui-document-picker';

export default class MediaService {
    showCameraPicker() {
        openFilePicker({
            extensions: 'jpg',
            multipleSelection: true,
        });
    }
    showGalleryPicker() {
        openFilePicker({
            extensions: 'jpg',
            multipleSelection: true,
        });
    }
    showFilePicker() {
        openFilePicker({
            extensions: 'pdf',
            multipleSelection: true,
        });
    }
}
farfromrefug commented 2 years ago

@xpalacincreditoh the errors tells you that extensions should be an array