import { ImageAsset } from '@nativescript/core/image-asset' ; import { alert } from '@nativescript/core/ui/dialogs' ; import { ImagePicker , ImagePickerMediaType } from '@nativescript/imagepicker' ; class FilePicker extends ImagePicker { get mimeTypes ( ) { const mimeTypes = Array . create ( java . lang . String , 1 ) ; mimeTypes [ 0 ] = '*/*' ; return mimeTypes ; } } export function openFilePicker ( ) { const filePicker = new FilePicker ( { mode : 'single' , mediaType : ImagePickerMediaType . Any , showAdvanced : true , } ) ; return filePicker . authorize ( ) . then ( ( ) => filePicker . present ( ) ) . then ( ( selection ) => { const filePath = selection [ 0 ] . android ; if ( ! filePath ) { alert ( 'Failed to access the selected file.' ) ; } return filePath ; } ) . catch ( ( error ) => { if ( error . message === 'Image picker activity result code 0' ) { return null ; } else { throw error ; } } ) ; }