http://cloudinary.com/documentation/image_upload_api_reference#upload
I tried the following:
user picks from camera roll:
{
data: "/9j/4AAQSkZJRgABAQAASABIAAD/4QBYRXhpZg..."
origURL: "assets-library://asset/asset.JPG?id=ED7AC36B-A150-4C38-BB8C-B6D696F4F2ED&ext=JPG",
uri: "file:///Users/me/Library/Developer/CoreSimulator/Devices/1BC4A449-46CF-4ADE-A9B5-78906C9C50FB..."
}
then on the server (Node.js), I am trying to use uri
from above:
addUserPhoto(uri) {
const photo = new Promise((resolve, reject) => {
const base64URI = new Buffer(uri).toString('base64');
cloudinary.v2.uploader.upload('data:image/jpeg;base64,'+base64URI, {}, (result) => {
console.log(result);
resolve(result);
});
});
return photo;
}
But I get the error:
{ message: 'Invalid image file', http_code: 400 }
Am not sure about the correct "file". What am I doing wrong? Which field am I supposed to pick from the camera roll data, and how do I convert it to a compatible "file" for Cloudinary API?