HarmonyOS photoAccessHelper.getAssets报错:errCode:14000014 errMsg:member not exist
通过photoViewPicker取得照片的uri后,再使用photoAccessHelper.getAssets,出现报错:
errCode:14000014 errMsg:member not exist
工程机版本:ALT-AL10 3.0.0.22(SP35DEVC00E22R6P1log)
DevEco Studio版本:5.0.3.200
SDK版本:5.0.0.22
async handle():void{
const count =4;
const photoSelectOptions = new photoAccessHelper.PhotoSelectOptions();
photoSelectOptions.MIMEType = photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE; // 过滤选择媒体文件类型为IMAGE
photoSelectOptions.maxSelectNumber = count; // 选择媒体文件的最大数目
const photoViewPicker = new photoAccessHelper.PhotoViewPicker();
try {
const photoSelectResult: photoAccessHelper.PhotoSelectResult = await photoViewPicker.select(photoSelectOptions);
const uris = photoSelectResult.photoUris;
console.info('photoViewPicker.select to file succeed and uris are:' + uris);
const tempImgs: Array<TempImage> = [];
for (let i = 0 ; i < uris.length ; i++) {
const tempImg = await getImageInfo(uris[i], getContext(this));
tempImgs.push(tempImg);
}
} catch (err) {
return this.onFailure(-1, `selectImages error occurs. ${err}`);
}
}
async function getImageInfo(uri: string, context: Context): Promise<TempImage> {
let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
predicates.equalTo(photoAccessHelper.PhotoKeys.URI, uri.toString());
let fetchOptions: photoAccessHelper.FetchOptions = {
fetchColumns: [],
predicates: predicates
};
let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
const PhotoKeys = photoAccessHelper.PhotoKeys;
const pixelMap = await photoAsset.getThumbnail({ width: 120, height: 120 })
const base64 = await converToBase64(pixelMap);
const result: TempImage = {
file_size: photoAsset.get(PhotoKeys.SIZE) as number,
file_type: convertToFileType(photoAsset.photoType) as number,
image_height: photoAsset.get(PhotoKeys.HEIGHT) as number,
image_width: photoAsset.get(PhotoKeys.WIDTH) as number,
original_height: photoAsset.get(PhotoKeys.HEIGHT) as number,
original_width: photoAsset.get(PhotoKeys.WIDTH) as number,
path: uri, // "file:///private/var/mobile/Containers/Data/Application/D64C9CD3-3E33-412C-BFCC-1BAEFF52887B/tmp/0DF557E6-ED48-4696-BB94-8C4104A67870"
path_uri: uri, // "/tmp/0DF557E6-ED48-4696-BB94-8C4104A67870"
thumb: base64
}
console.info('base64: ' + base64);
fetchResult.close();
return result;
}
HarmonyOS
赞
收藏 0
回答 1
待解决
相关问题
HarmonyOS调用PhotoAccessHelper.getAssets问题
462浏览 • 1回复 待解决
HarmonyOS 中photoAccessHelper获取图片大小报错
520浏览 • 1回复 待解决
报错Property 'pushUrl' does not exist on type 'typeof router'.
3606浏览 • 1回复 待解决
在DevEco Studio中出现The <form> component does not exist.报错信息
6416浏览 • 1回复 待解决
如何解决编译报错“Property xxx does not exist on type 'typeof BuildProfile'
3227浏览 • 1回复 待解决
HarmonyOS photoAccessHelper.PhotoAsset set 支持哪些?
355浏览 • 0回复 待解决
HarmonyOS photoAccessHelper 相册管理模块的使用
328浏览 • 1回复 待解决
BuildProfile自定义字段报错:Property 'BUILD_VERSION' does not exist on type 'typeof BuildProfile'
735浏览 • 1回复 待解决
HarmonyOS photoAccessHelper如何获取所有相册的信息
554浏览 • 1回复 待解决
HarmonyOS photoAsset读取photoAccessHelper.PhotoKeys.SIZE失败
263浏览 • 1回复 待解决
错误码9568305怎么处理,安装hap时报错:dependent module does not exist
1508浏览 • 1回复 待解决
HarmonyOS photoAccessHelper 获取的图片资源无法获取图像宽高
243浏览 • 1回复 待解决
HarmonyOS photoAccessHelper 能否通过 uri 获取对应的图片obj
362浏览 • 1回复 待解决
HarmonyOS photoAccessHelper.PhotoAsset获取录屏时长不精确
240浏览 • 1回复 待解决
相册权限问题:phAccessHelper.getAssets方法需要ohos.permission.READ_IMAGEVIDEO权限
2016浏览 • 1回复 待解决
The <canvas> component does not exist.
8474浏览 • 3回复 待解决
code:9568305 error: dependent module does not exist.
3061浏览 • 1回复 待解决
HarmonyOS 图片写入用户图库后,马上调用 getAssets,无法获取到刚存入的照片?
380浏览 • 1回复 待解决
HarmonyOS photoAccessHelper获取到的图片资源,有对应的uuid获取吗
459浏览 • 1回复 待解决
#鸿蒙通关秘籍#如何使用 PhotoAccessHelper 替代 PhotoViewPicker 选择图片?
81浏览 • 1回复 待解决
XTS测试 acts 提示 required device does not exist
10176浏览 • 4回复 待解决
开发蓝牙模块时,出现errCode:-4,errMessage:Inner error.怎么回事啊?
2608浏览 • 1回复 待解决
启动UIAbility报The specified ability does not exist 错误是什么原因?
720浏览 • 1回复 待解决
请将IDE升级到canary3版本,5.0.3.300重新编译成员参数名称,在get时,除了uri、photoType和displayName三个属性之外,其他的属性都需要在fetchColumns中填入需要get的PhotoKeys,例如:get title属性fetchColumns: [‘title’]。
https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-photoaccesshelper-V5#ZH-CN_TOPIC_0000001893368817__get