Can I upload using DATA URI (BASE64)?

In addition to being able to upload from a local path or a remote URL, Cloudinary also supports uploading your assets (images, videos, documents, etc.) using the Base64 DATA URI scheme as explained here.

Such an upload call will look something like this (Rails):

Cloudinary::Uploader.upload(data:[<MIME-type>][;charset=<encoding>][;base64],<data>);

For example, the following command:

Cloudinary::Uploader.upload("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==")

Will result in uploading the following PNG image: 

If one prefers to generate the HTTP request on their own, note that the DATA URI must be first url-escaped, for example (using the same image from above):

"data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4%2F%2F8%2Fw38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg%3D%3D"

For information regarding client-side BASE64 uploading, please visit the following link:
http://support.cloudinary.com/hc/en-us/articles/202519992-How-to-upload-a-Base64-DataURI-string-of-an-image-directly-from-the-browser-

UPDATE: Uploading using Base64 representation is limited to file-size of 60MB.

Have more questions? Submit a request

Comments

Powered by Zendesk