[英]i m stuck in upload image on firebase cloud firestore. Can anyone help me .?
const { user_id, username } = this.props;
const { imagePath } = this.state;
const fileExtension = imagePath.split(".").pop();
console.log("EXT: " + fileExtension);
var uuid = uuidv4();
const fileName = `${uuid}.${fileExtension}`;
console.log("fiile name ---> " + fileName);
this.setState({ profile_image : fileName });
And和
export const addManualContact =
(username, profile_image ) => {
firebase.firestore().collection('user').doc(`${username}`).collection('contacts').add({ profile_image: profile_image }) }
The problem was my library import ImagePicker from "react-native-image-crop-picker";
问题是我的库
import ImagePicker from "react-native-image-crop-picker";
Here is function:这是 function:
//Here is take photo from gallery
takePhotoFromCamera2 = () => {
ImagePicker.openCamera({
width: 300,
height: 400,
cropping: true,
}).then((image2) => {
this.setState({ profile_image2: image.path });
console.log(image2);
this.setState({
image2: {
uri: image2.path,
width: image2.width,
height: image2.height,
mime: image2.mime,
},
images: null,
});
});
};
and I upload the image in Firestore like this:我像这样在 Firestore 中上传图像:
firebase.firestore()
.collection("user")
.doc(`${username}`)
.update({ profile_image: profile_image });
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.