本文介绍了Nativescript:如何从图库中获取照片列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问题是我需要自动从图库中获取照片.我读过ImagePicked用于从图像存储中拾取照片,但它只是以手动方式提供(用户自行完成).是否有机会访问画廊,拍摄照片列表并在应用程序中使用它们?当然,是否可以按条件过滤它们(按日期范围获取照片)?
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,在Android上,您可以尝试以下操作:
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);
});
这篇关于Nativescript:如何从图库中获取照片列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!