You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
toki4004
2 years agoHelpful | Level 5
Upload string value to file - PHP
I need to upload a simple string via api - there is no "file" on the server - the string will be generated in my PHP code. First, does it need to be in binary? Second, when I upload, I get a "1" writ...
- 2 years ago
The /2/files/upload endpoint is a "content-upload" style endpoint, meaning that it expects the raw bytes of the file data in the HTTPS request body (with corresponding "application/octet-stream" type, as you have).
Exactly how you retrieve that data and configure your HTTPS client to send it like that is up to you. Please note that we can't provide support for configuring third party clients themselves, as they're not made by Dropbox, so you may need to refer to the documentation for the client you're using for information on how to configure it.
That said, looking at the code you shared, it looks like you might want to do the following, instead of your current 'CURLOPT_POSTFIELDS' and 'CURLOPT_INFILE' usage:
curl_setopt($ch, CURLOPT_POSTFIELDS, $string);
Greg-DB
Dropbox Staff
The /2/files/upload endpoint is a "content-upload" style endpoint, meaning that it expects the raw bytes of the file data in the HTTPS request body (with corresponding "application/octet-stream" type, as you have).
Exactly how you retrieve that data and configure your HTTPS client to send it like that is up to you. Please note that we can't provide support for configuring third party clients themselves, as they're not made by Dropbox, so you may need to refer to the documentation for the client you're using for information on how to configure it.
That said, looking at the code you shared, it looks like you might want to do the following, instead of your current 'CURLOPT_POSTFIELDS' and 'CURLOPT_INFILE' usage:
curl_setopt($ch, CURLOPT_POSTFIELDS, $string);
toki4004
2 years agoHelpful | Level 5
Yes, that worked! Thanks,
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,911 PostsLatest Activity: 3 hours agoIf you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!