cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
We're looking to hear about your experience when using Dropbox in a web browser. What parts of Dropbox feels very slow to you and takes a lot of time to get done? What are you trying to do in the Dropbox web browser when you experience slowness? Tell us right here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
1
Ask
2
Reply and help

The Dropbox API V2 not compatible with React Native

The Dropbox API V2 not compatible with React Native

matt-42
Explorer | Level 3

I am not able to use the filesUpload endpoint with react native.

Simply because it is not possible with React Native to set the content type to one of the 'Content-Type' header accepted by the API. I get the following error: 

 

Error in call to API function "files/upload": Bad HTTP "Content-Type" header: "application/octet-stream; charset=utf-8".  Expecting one of "application/octet-stream", "text/plain; charset=dropbox-cors-hack

 

 

 

Is there any workaround ?

 

I'm not alone with this problem:

https://github.com/square/okhttp/issues/3081

https://github.com/square/okhttp/blob/master/okhttp/src/main/java/okhttp3/RequestBody.java#L53

https://github.com/facebook/react-native/issues/14445

 

4 Replies 4

Re: The Dropbox API V2 not incompatible with React Native

Greg-DB
Dropboxer
Thanks for the post. I don't have a workaround to offer on our side unfortunately, but I'm raising this with the engineering team to see if they can change that behavior. I can't make any promises though.

Re: The Dropbox API V2 not incompatible with React Native

Laurent22
Explorer | Level 4
Hello, have the engineering team had the opportunity to look into this bug? This is unfortunately still an issue with React Native and it means it's not possible to create apps that support Dropbox (see the GitHub issue there - https://github.com/facebook/react-native/issues/14445 ) Any chance it is going to be fixed on the Dropbox side?

Re: The Dropbox API V2 not incompatible with React Native

Greg-DB
Dropboxer

@Laurent22 Unfortunately I don't have any news on this from the team. 

Betreff: The Dropbox API V2 not compatible with React Native

tsoltermann
New member | Level 2

I have the same issue and after some hours fiddling around I was able to fix workaround it. I'm uploading a JSON file to a dropbox account and i used a TextEncoder like this:

 

 

var myFile_Encoded = new encoding.TextEncoder().encode(JSON.stringify(myFile));
dbx.filesUpload({
  path: DBX_FILEPATH,
  contents: myFile_Encoded,
  mode: 'overwrite',
});

  

This seemed to do the trick and it even worked with multibyte characters that require UTF-8. e.g. ä, ö, ü.
 
Don't know whether that helps you.
 
regards, Tobias
Who's talking

Top contributors to this post

  • User avatar
    tsoltermann New member | Level 2
  • User avatar
    Greg-DB Dropboxer
  • User avatar
    Laurent22 Explorer | Level 4
What do Dropbox user levels mean?
Need more support?