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
Amicao
3 years agoExplorer | Level 3
How to upload file via Curl with Binary object input?
Hello, good evening for all. I would like to know, how I can to upload file using a Curl request, or PHP Curl request, with the upload file request.
But instead I use the parameter o filepath, I us...
karanag
Explorer | Level 4
Hi,
I am facing kind of the same problem. My Code is below but it uploading a corrupted image, any ideas what exactly I am doing wrong? I am trying to build my app using no-code tool AppGyver
const imagePath = inputs.imagePath; // (This line takes the path of the image)
var path = "/Pictures/testPicturreABC12345.jpg";
var content = "@" + imagePath;
var accessToken = "sl.BLX6BjKTDsrOpArs74Bk32Pg09Ukns0u3YUCsDnoagiOJdx2hq6iCZezCKlWc-53v8E6IVOaU3Tu0OAOGMrxc5KIVeihAn51f5hZ0x3EKpCJdEKuykWIz4SAeC4WcjXpKiSrhWC8";
var result;
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
result = xhr.responseText;
return result;
}
};
xhr.open("POST", uploadUrl, true);
xhr.setRequestHeader("Authorization", "Bearer " + accessToken);
xhr.setRequestHeader("Content-type", "application/octet-stream");
xhr.setRequestHeader("Dropbox-API-Arg", '{"path": "' + path + '"}');
xhr.send(content);
Greg-DB
3 years agoDropbox Staff
karanag In your code, you're sending the data in your 'content' variable, which just contains the string '"@" + imagePath', not the actual file data at that path. In the examples in the Dropbox API documentation, the "@" is a way of telling curl on the command line to read from the local filesystem at that path. That wouldn't necessarily work in other environments, such as using XMLHttpRequest like you are here. You'll need to update your code to pass in the actual file data. Please refer to the documentation for your platform for information on accessing file data.
- karanag3 years agoExplorer | Level 4
Ahh, thanks! Will do a deep dive into the documentation
About Discuss Dropbox Developer & API
Make connections with other developers
797 PostsLatest Activity: 2 days 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!