[英]Nativescript: How to get photo list from gallery
问题是我需要自动从图库中获取照片。 我读过ImagePicked用于从图像存储中拾取照片,但它只是以手动方式提供(用户自行完成)。 是否有机会访问画廊,拍摄照片列表并在应用程序中使用它们? 当然,是否可以按条件过滤它们(按日期范围获取照片)?
GingerComa,在Android上,您可以尝试以下操作:
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);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.