0

I am using MongoDB for my database and want users in my app to be able to pick a profile picture. I am using expo-image-picker to select the image and then I save the result.uri to the database. An example of what I see in the database is: "file:///var/mobile/Containers/Data/Application/...file-name.jpg". I believe that is a local path to the image. If another user wants to see that image they cannot. From my research, it seems that I could convert this file to a base64 and then save that. Everything I have tried however, has not worked. Should I convert it to a base64? If so, how do I do it? If not then what other options do I have? Thanks.

Cole
  • 207
  • 2
  • 11
  • I figured out how to get it as a base64. Now the problem is that the string is over 11 million characters long. Does anyone know a way to shorten it while still keeping most of the data? – Cole Aug 05 '22 at 01:40
  • Dont use base64 because it's 30% larger in size then binary image instead use FormData post request to upload image to server with uri like this https://www.reactnativeschool.com/how-to-upload-images-from-react-native – Hardik Chavda Aug 05 '22 at 05:05
  • Maybe you can use something like Cloudinary to store your images. When you upload images to it, it will give you a url that links to that image. Then save that url to your database. – caslawter Aug 05 '22 at 06:34

0 Answers0