Last active
April 21, 2018 20:14
-
-
Save dzeitman/00b1683b9eee0cecce92479afa971be8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
1> Create a webtask. | |
2> Add NPM Module for Cloudinary | |
3> Add secrets for your cloud, api_key and api_secret | |
*/ | |
var cloudinary = require("cloudinary"); | |
function autoTagByID(context, cb){ | |
var public_id = context.query.public_id || "flooded_road_1"; //existing asset if none passed | |
var options = { categorization: "google_tagging,imagga_tagging,aws_rek_tagging", | |
auto_tagging: 0.6, type:"upload" }; | |
cloudinary.v2.uploader.explicit(public_id,options, function(error,result) { | |
if(error){ | |
cb(error); | |
} | |
if(result){ | |
console.log(result); | |
cb(null, result); | |
} | |
}); | |
} | |
function findByTag(context, cb){ | |
var tag = context.query.tag || "imageCon"; | |
var options ={context:true, tags:true, max_results:500}; | |
cloudinary.v2.api.resources_by_tag(tag, options, | |
function(error, result){ | |
if(error){ | |
cb(error); | |
} | |
console.log(result); | |
cb(null, result); | |
}); | |
} | |
module.exports = function(context, cb) { | |
cloudinary.config({ | |
"cloud_name": context.secrets.cloud_name, | |
"api_key": context.secrets.api_key, | |
"api_secret": context.secrets.api_secret | |
}); | |
autoTagByID(context,cb) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment