我可以使用Ionic Image Picker插件获取图像URI :this.imagePicker.getPictures(options).then((results) => { for (var i = 0; i < results.length; i++) { //below logs: 'Image URI: file:///Users/josh.0/Library/Developer/CoreSimulator/Devices/CC0FFBD2-EADF-4489-8F22-7948E0EFD261/data/Containers/Data/Application/2BC3C571-61B7-4EFF-A4D1-4D1F99F04EBC/tmp/cdv_photo_013.jpg' console.log('Image URI: ' + results[i]); }}, (err) => { });我需要以文件的形式获取此图像,因此可以上载它。我已尝试执行以下操作,但不起作用:this.imagePicker.getPictures(options).then((results) => { for (var i = 0; i < results.length; i++) { console.log('Image URI: ' + results[i]); let base64Image = "data:image/jpeg;base64," + results[i]; fetch(base64Image) .then(res => res.blob()) .then(blob => { //Doesnt fire console.log("Got blob") const file = new File([blob], "image.png") }) }}, (err) => { });如何将图像URI转换为文件?
添加回答
举报
0/150
提交
取消