简体   繁体   中英

Nativescript: How to get photo list from gallery

The thing is I need to get photos from gallery automatically. I've read that ImagePicked is used to pick up photo from image store but it provides just in manual way (user does it by self). Are there any opportunity get access to gallery, take list of photos and used them in an application? Of course if are is it possible to filter them by criteria (get photos by date range)?

GingerComa, on Android you could try this:

import * from "file-system";

var tempPicturePath = android.os.Environment.getExternalStoragePublicDirectory(android.os.Environment.DIRECTORY_DCIM).getAbsolutePath();

var folder : Folder = Folder.fromPath(tempPicturePath);

folder.getEntities()
    .then(entities => {
        // entities is array with the document's files and folders.
        entities.forEach(entity => {
            // console.log(entity.name);
            // console.log(entity.path);
            // console.log(entity.lastModified);
            this.folderEntities.push(
                new FolderEntity(entity.name, entity.path, entity.lastModified.toString())
            );
        });
    }).catch(err => {
        // Failed to obtain folder's contents.
        console.log(err.stack);
    });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM