Reactjs 如何将本地映像共享给Firebase,然后检索我在React Native中登录的任何设备?
我正在尝试将图像发布到Firebase实时数据库。直到现在,我已经成功地做到了这一点,图像可以显示,但只有当我仍然连接应用程序,还没有重新加载 我知道原因是因为我在数据库上发布的Reactjs 如何将本地映像共享给Firebase,然后检索我在React Native中登录的任何设备?,reactjs,react-native,firebase-realtime-database,redux,react-native-firebase,Reactjs,React Native,Firebase Realtime Database,Redux,React Native Firebase,我正在尝试将图像发布到Firebase实时数据库。直到现在,我已经成功地做到了这一点,图像可以显示,但只有当我仍然连接应用程序,还没有重新加载 我知道原因是因为我在数据库上发布的uri类型如下: content://com.google.android.apps.photos.contentprovider/0/1/content%3A%2F%2Fmedia%2Fexternal%2Fimages%2Fmedia%2F58/ORIGINAL/NONE/image%2Fjpeg/484166561
uri
类型如下:
content://com.google.android.apps.photos.contentprovider/0/1/content%3A%2F%2Fmedia%2Fexternal%2Fimages%2Fmedia%2F58/ORIGINAL/NONE/image%2Fjpeg/484166561
以下是Redux操作中用于添加帖子的代码:
export const addPost = (postImage, date, description, checkin_location) => {
return async (dispatch, getState) => {
const token = getState().auth.user.token;
const userId = getState().auth.user.uid;
const response = await fetch(
`https://..../users/${userId}/posts.json?auth=${token}`, {
method: 'POST',
headers:{
'Content-Type': 'application/json'
},
credentials: 'same-origin',
body: JSON.stringify({
postImage,
date,
description,
checkin_location,
})
});
const resData = await response.json();
console.log(resData);
if(!response.ok){
console.log("reponse isn't ok in post action ", response)
};
dispatch({
type: ADD_POST,
postData:{
id: resData.name,
ownerId: userId,
postImage,
date,
description,
checkin_location
}
})
}
}
为了实现这一目标,我应该做些什么
或者更准确地说,我如何将uri
链接转换为url
或至少是Image
组件可以显示的类型,即使在我重新加载或由其他设备登录时也是如此
我正在使用实时数据库,听说过Firestore和云功能,但还没有使用过
请帮忙