【发布时间】:2021-07-15 07:35:21
【问题描述】:
我有 expo 项目,我使用 expo-image-picker 从设备中选择 img,但它只返回 uri and base64 data not actual File,我需要将此图像发送到 django,它应该验证为 ImageField
我尝试使用 b64-to-blob(npm) 将 base64 转换为 blob,但 atob 在 react native android 中不可用,我还尝试使用 fetch API 创建博客,但它在 Andoid 上提供了Network error
let result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: ImagePicker.MediaTypeOptions.Images,
allowsEditing: true,
aspect: [4, 3],
quality: 0.5,
base64: true,
});
console.log(result)
/*
{
height: "some num",
width: "some num",
...
uri: "file://file_in_device",
base64: "base64 string"
}
*/
【问题讨论】:
标签: javascript react-native fetch expo blob