【发布时间】:2022-01-27 22:45:48
【问题描述】:
我正在使用 expo-image-picker,如果我在 android 模拟器中选择一个图像并保存它,当我使用我的真实设备进入程序时,我看不到我从模拟器中保存的图像。换句话说,无论我用哪个设备保存图片,它都只会出现在那个设备上。它不会出现在其他设备上。我该如何解决这个问题?
我正在使用 API 进行数据库操作(使用 axios)
这是代码
const PickImage = async () => {
allowPhotoRequests()
let result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: ImagePicker.MediaTypeOptions.All,
allowsEditing: true,
aspect: [4, 3],
quality: 1,
base64: true
})
if (!result.cancelled) {
setImage(result.uri) // I think I have to do something here
}
提交代码:
const addPet = async () => {
try {
petApi.post('/', {
userId: userId,
Age: age,
Weight: weight,
userName: currentUser,
userPhone: currentUserPhone,
petImage: image,
city: city,
district: district
})
.then(function (response) {
alert('Success!')
})
}
catch (error) {
console.log(error);
}
}
图像输出示例:
file:///data/user/0/host.exp.exponent/cache/ExperienceData/%2540yas1nkiziltas%252FPettyApp/ImagePicker/cb2923b3-5de8-4692-8244-0ce9b987001a.jpg
【问题讨论】:
标签: react-native axios expo