在拿到uri后调用file接口获取文件大小,详情见:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/photoaccesshelper-photoviewpicker-V5\#指定uri读取文件数据let uris: Array<string> = []; const photoViewPicker = new photoAccessHelper.PhotoViewPicker(); photoViewPicker.select(photoSelectOptions).then((photoSelectResult: photoAccessHelper.PhotoSelectResult) => { uris = photoSelectResult.photoUris; console.info('photoViewPicker.select to file succeed and uris are:' + uris); let uri: string = ''; let file = fileIo.openSync(uri, fileIo.OpenMode.READ_ONLY); console.info('file fd: ' + file.fd); let buffer = new ArrayBuffer(4096); let readLen = fileIo.readSync(file.fd, buffer); console.info('readSync data to file succeed and buffer size is:' + readLen); }).catch((err: BusinessError) => { console.error(`Invoke photoViewPicker.select failed, code is ${err.code}, message is ${err.message}`); })
在拿到uri后调用file接口获取文件大小,详情见:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/photoaccesshelper-photoviewpicker-V5\#指定uri读取文件数据