I have seen that this issue has been presented a few times before however, those solutions haven't helped in completed this last task for my app.
I am using React Native with Expo. I am using Image Picker to select an image from iOS, and getting the uri suck as 'file:///var/mobile/Containers/Data/Application/9A9F8016-CB14-4772-BF42-91DC74EA40CC/Library/Caches/ExponentExperienceData/%2540anonymous%252Fheritagefilmsapp-5de39698-e6f1-4070-83cc-562fa650fca5/ImagePicker/855BDF4B-97F3-413C-BADA-F278CE645FAE.png'
I think I need to convert the uri image into binary data but for the life of me don't understand how to do that.
The /2/files/upload endpoint is a "content-upload" style endpoint, meaning that it requires the file data to be uploaded in the request body. I see you're attempting to set the file data as such by using the "body" parameter in your "requestOptions" that you pass to "fetch".
That seems correct, but you'll need to make sure your "file" variable contains the actual file data you want to upload.
I understand you currently just have the URL for local file data though; not the file data itself. You'll need to read the data from the local filesystem in order to pass the data along. I'm afraid I can't offer much guidance on doing so though as that's not related to the Dropbox API itself. You may need to refer to the relevant iOS documentation from Apple (or otherwise React/Expo if they offer functionality for this).
I was able to read the base64 data that I got back and then used that to upload. So I am uploading a variable that has the base64 stuff and now the upload is 1.06mb but is still corrupted/not viewable. Any idea?
let data = result.uri.split(",");
When you upload data to Dropbox via the API, you should upload the actual file data, without any encoding (such as base64 encoding). Dropbox does not apply any decoding on the uploaded file data; it will just commit what you send. Try uploading the data without the base64 encoding.
We love to learn from the educators who use Dropbox. Whether you teach kids, teens, adults or a combination of all three, we want to know what apps and integrations you use with Dropbox to help with teaching. Which of the ones below is your favorite, or most used tool?