A small loopback component that acts as a cloudinary datasource. Only image upload is supported is supported currently.
npm install loopback-component-cloudinary
image.js
module.exports = function(Image) {
};
image.json
{
"name": "Image",
"plural": "images",
"base": "Model",
"options": {},
"properties": {},
"validations": [],
"relations": {},
"acls": [],
"methods": {}
}
datasource.json
{
"cloudinary": {
"name": "cloudinary",
"connector": "loopback-component-cloudinary",
"config": {
"cloud_name": "your_cloud_name",
"api_key": "your_api_key",
"api_secret": "your_api_secret"
}
}
}
Optionally define upload default parameters:
{
"cloudinary": {
"name": "cloudinary",
"connector": "@kolach/loopback-component-cloudinary",
"config": {
"cloud_name": "your_cloud_name",
"api_key": "your_api_key",
"api_secret": "your_api_secret"
},
"upload": {
"tags": "staging, flickr",
"folder": "important"
}
}
}
This configuration will automatically add staging and flickr tags, and setup root folder as important
To override default tags and folder you may add tags
and folder
fields into form you're sending.
model.config.json
{
...
"Image": {
"dataSource": "cloudinary",
"public": true
}
}
The configuration above will add POST ${restApiRoot}/images/upload url.