Skip to content

Android: How to get file extension of images selected using @nativescript/imagepicker #338

Open
@SaadmanGTM

Description

@SaadmanGTM

Hello, I am using @nativescript/imagepicker to select multiple images on android.
I would like to only keep the images which have .jpg, .jpeg, and .png extensions.

I am checking the URI using selection[0].android, but the result is:
content://com.android.providers.media.documents/document/image%3A52
It contains the image name, but not the file extension.

How can I get the file extension using imagepicker?

This is my implementaiton:

var context = imagePicker.create({
    mode: 'multiple',
    showsNumberOfSelectedAssets: true,
    mediaType: ImagePickerMediaType.Image
})

context
    .authorize()
    .then(function () {

        return context.present()
    })
    .then(function (selection) {

        fileURI = selection[0].android;
        console.log(fileURI);

...

I am using:

@nativescript/core: v8.0.2
@nativescript/imagepicker: v1.0.6

How to get the file extension?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions