Javascript 如何将图像上载到firebase
我想让用户能够上传自己的个人资料图像,并在react native javascript中显示:Javascript 如何将图像上载到firebase,javascript,firebase,react-native,firebase-storage,Javascript,Firebase,React Native,Firebase Storage,我想让用户能够上传自己的个人资料图像,并在react native javascript中显示: 用户可以转到图像上传页面并更改自己的配置文件图像 使用用户的uid名称将图像存储在firebase存储中 在配置文件页面中仅检索用户的图像 我想将拾取的图像上载到firebase存储 我可以用世博会图像选择器拾取和显示图像 代码: 您可以尝试将图像转换为base64格式并将其插入firebase。这些代码似乎都没有将图像上载到firebase。如果您对此代码有问题,请编辑您的问题,以指示哪一行没
- 用户可以转到图像上传页面并更改自己的配置文件图像
- 使用用户的uid名称将图像存储在firebase存储中
- 在配置文件页面中仅检索用户的图像
- 我想将拾取的图像上载到firebase存储
您可以尝试将图像转换为base64格式并将其插入firebase。这些代码似乎都没有将图像上载到firebase。如果您对此代码有问题,请编辑您的问题,以指示哪一行没有完成您期望它完成的任务。如果您想知道如何将文件上载到Firebase,请参阅
state = {
image: null,
};
componentDidMount() {
this.getPermissionAsync();
}
getPermissionAsync = async () => {
if (Platform.OS !== "web") {
const { status } = await Permissions.askAsync(Permissions.CAMERA_ROLL);
if (status !== "granted") {
alert("Sorry, we need camera roll permissions to make this work!");
}
}
};
_pickImage = async () => {
try {
let result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: ImagePicker.MediaTypeOptions.Images,
allowsEditing: true,
aspect: [12, 16],
quality: 1,
});
if (!result.cancelled) {
this.setState({ image: result.uri });
}
console.log(result);
} catch (E) {
console.log(E);
}
};