代码如下
const result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: ImagePicker.MediaTypeOptions.All,
allowsEditing: true,
aspect: [4, 3],
base64: true
});
if (result.cancelled) {
return;
}
var data = {base64: result.base64}
var file = new AV.File("avatar.jpg", result.base64);
var fileId = "";
file
.save({
onprogress: progress => {
console.log(progress);
// {
// loaded: 1024,
// total: 2048,
// percent: 50
// }
}
})