cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Back again with another edition of 'How we use Dropbox', so find out how Emma uses to-do lists to get it all done 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: 

Upload Image Base64 Encoded with Dropbox API

Upload Image Base64 Encoded with Dropbox API

PHDev
Explorer | Level 3

Hi, I'm trying to use dropbox API for uploads images, actually I have the Base64 encoded string of image file and I wanna use the API for upload. I try this but it doesn't work.

  curl -X POST https://content.dropboxapi.com/2/files/upload \
    --header "Authorization: Bearer <TOKEN>" \
    --header "Dropbox-API-Arg: {\"path\": \"/test/img.jpg\",\"mode\": \"add\",\"autorename\": true,\"mute\": false}" \
    --header "Content-Type: application/octet-stream" \
    --data-binary "<Base64 Encoded Image Here>"

I wanna know if I can upload images encoded in Base64.

 

Thanks.

1 Reply 1

Re: Upload Image Base64 Encoded with Dropbox API

chirstius
Dropboxer

Hello @PHDev,

 

Can you clarify if you are trying to store the literal Base64 encoding or if your end goal is to upload Base64 and have Dropbox store the resulting image that the Base64 data represents?

 

Base64 conversion is not supported by the upload API endpoints. So if you are trying to store the resulting images, you will need to "reconstitute" the image file back to its binary format before you upload it.

 

If instead, you are trying to store the literal Base64 encoding of the image, you will still need to convert that data to bytes before uploading it and then decode it when you pull it back down.

 

Hope that helps,

 

-Chuck

Who's talking

Top contributors to this post

  • User avatar
    chirstius Dropboxer
What do Dropbox user levels mean?
Need more support?