【发布时间】:2018-01-30 05:32:07
【问题描述】:
问题是我需要自动从图库中获取照片。我读过 ImagePicked 用于从图像存储中获取照片,但它仅以手动方式提供(用户自行完成)。 是否有机会访问图库、列出照片并在应用程序中使用它们? 当然是否可以按条件过滤它们(按日期范围获取照片)?
【问题讨论】:
标签: javascript angular typescript mobile nativescript
问题是我需要自动从图库中获取照片。我读过 ImagePicked 用于从图像存储中获取照片,但它仅以手动方式提供(用户自行完成)。 是否有机会访问图库、列出照片并在应用程序中使用它们? 当然是否可以按条件过滤它们(按日期范围获取照片)?
【问题讨论】:
标签: javascript angular typescript mobile nativescript
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);
});
【讨论】: