This is a blaze-only package! Cloudinary provides a simple way for uploading files to Cloudinary, which in turn can be set up to sync with your Amazon S3 service. This is useful for uploading and actively manipulating images and files that you want accesible to the public. Cloudinary is built on Cloudinary (NPM) and Cloudinary (JS). Installing this package will make Cloudinary available server-side and cloudinary available client-side (cloudinary_js feels unstable in certain situations).
This is a quick implementation of the uploader, feel free to fork it and improve on it like so many people did for S3 ^_^. I'm always open for pull requests too.
This package does not use Session variables for reactivity anymore. You can identify whether an upload is successful via the new helper c.uploading_images or your own collection.
There is a new global helper that contains all cloudinary helpers, it takes the namespace of "c". This means:
You can now upload a stream of data via the c_upload_stream template and view progress via the c.uploading_images helper.
$ mrt add cloudinary
Configure your Cloudinary Credentials. SERVER SIDE AND CLIENT SIDE.
//SERVER
Cloudinary.config({
cloud_name: 'cloud_name',
api_key: '1237419',
api_secret: 'asdf24adsfjk'
});
//CLIENT
$.cloudinary.config({
cloud_name:"cloud_name"
});
Create a Cloudinary input with a callback function. CLIENT SIDE.
Or a Cloudinary stream input with a callback function. CLIENT SIDE.
Define a callback function that will handle what to do with Cloudinary's response. Usually just save the url to a collection. SERVER SIDE.
Meteor.methods({
save_url:function(response){
console.log('Add '+response.upload_data+' to the id of '+response.context);
}
});
All of Cloudinary's manipulation options are available in the c.url helper. You can access an image by passing a cloudinary public_id and format:
You can manipulate an image by adding parameters to the helper
You can use the collection-hooks package to hook up to the data stream.
Install collection hooks (mrt add collection-hooks)
Hook up to cloudinary's client-side collection (_cloudinary).
_cloudinary.after.update(function(user,file){
if(file.percent_uploaded === 100 && !file.uploading){
console.log(file);
}
})
Here are all the transformations you can apply: http://cloudinary.com/documentation/image_transformations#reference
Images that are being processed appear under the c.uploading_images helper. This helper only contains percent_uploaded (out of 100) and total_uploaded (in bytes).
Just pass the public_id of the image or file through this function (security features pending). It will return an object with a list of the images deleted as a result.
Meteor.call("cloudinary_delete","public_id",function(e,r){
if(!e){
console.log(r);
}
});
This package is not intrusive on your database. It uses meteor-stream to connect to a clients' local collection and modify it. Because of this it is actually faster and more accurate with data. The local collection uses the _cloudinary namespace (so _cloudinary.find()).
I still need to add more configuration options and better error handling.