I’m not sure how to get the absolute path to the file… I’m using react-dropzone
following this:
but instead of client-side call using superagent, I’m using a method with the cloudinary npm package:
import { Meteor } from 'meteor/meteor';
import cloudinary from 'cloudinary';
cloudinary.config({
cloud_name: 'myname',
api_key: 'mykey',
api_secret: 'mysecret'
});
Meteor.methods({
uploadImg: function(file){
check(file, String);
console.log(file); //outsputs 'my-image.jpg'
cloudinary.uploader.upload(file, function(error, result) {
if (error) {console.log(error); return;} //outputs: { error: { [Error: ENOENT, open 'my-image.jpg'] errno: 34, code: 'ENOENT', path: 'my-image.jpg' } }
console.log('it worked');
});
return;
}
});
I was passing the uploadImg method file.name
from this object:
{ lastModified:1471614351000
lastModifiedDate:Fri Aug 19 2016 09:45:51 GMT-0400 (EDT)
name:"my-image.jpg"
preview:"blob:http://localhost:3000/b13a29ad-0835-4f2c-b9ce-f53c8387eac3"
size:51960
type:"image/jpeg"
webkitRelativePath : ""
}