Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function logExampleJSON(){
console.warn("Example:")
var exampleJSON = {
cloud_name: 'your cloud name',
api_key: 'your api key',
api_secret: 'your api secret'
};
console.log(prettyjson.render(exampleJSON, {
noColor: false
}));
}
var configDic = JSON.parse(fs.readFileSync(confPath,'utf8'))
if (configDic) {
cloudinary.config(configDic);
}else {
console.warn("config file format errorh");
logExampleJSON();
progress.exit();
}
if (!fs.existsSync(syncDirPath)){
fs.mkdirSync(syncDirPath);
}
function performUploadByFilePath(filePath){
log(`File ${filePath} has been added`);
// File upload stream
var stream = cloudinary.uploader.upload_stream(function(result) {
console.log(result)
next();
}
// upload image to cloudinary.com
var config = {
cloud_name: '',
api_key: '',
api_secret: ''
};
if (config.api_secret) {
var cloudinary = require('cloudinary'),
fs = require('fs'),
path = require('path');
cloudinary.config(config);
}
exports.postSave = function (req, res, args, next) {
if (args.debug) console.log('postSave');
debugger;
// upload image to a third party server
if (args.name == 'item') {
// provide your credentials to cloudinary.com
if (!config.api_secret) return next();
// file upload control data
var image = args.upload.view.item.records[0].columns.image;
// in case file is chosen through the file input control
if (image.name) {
// file name of the image already uploaded to the upload folder
var fname = args.data.view.item.records[0].columns.image;
import cloudinary from "cloudinary";
import * as fs from "fs-extra";
import md5 from "md5";
import * as path from "path";
import { env } from "process";
import request from "request-promise-native";
if (env.CLOUDINARY_CLOUD_NAME) {
cloudinary.config({
cloud_name: env.CLOUDINARY_CLOUD_NAME,
api_key: env.CLOUDINARY_API_KEY,
api_secret: env.CLOUDINARY_API_SECRET,
});
// FIXME: Likely this should be called somewhere else (app init)
initImageRegistry();
}
let resources: Array<{ id: string; url: string; md5?: string }> = [];
function initImageRegistry() {
cloudinary.api.resources(
result => {
if (!result.resources) {
throw new Error("No image resources!");
import cloudinary from 'cloudinary';
import dotEnv from 'dotenv';
dotEnv.config();
/*
Configure cloudinary using enviroment variables
Check .env.example for a template of setting the enviroment variables.
*/
cloudinary.config({
cloud_name: process.env.CLOUDINARY_CLOUD_NAME,
api_key: process.env.CLOUDINARY_API_KEY,
api_secret: process.env.CLOUDINARY_API_SERCRET,
});
/*
This function handle the asynchronous action of uploading an image to cloudinary.
The cloudinary.v2.uploader.upload_stream is used because we are sending a buffer,
which the normal cloudinary.v2.upload can't do. More details at https://github.com/cloudinary/cloudinary_npm/issues/130
*/
export const uploadImage = (image) => {
const cloudinaryOptions = {
resource_type: 'raw',
folder: process.env.CLOUDINARY_CLOUD_FOLDER || '',
}
return new Promise((resolve, reject) => {
import cloudinary from 'cloudinary';
import uuid from 'uuid/v4';
cloudinary.config({
cloud_name: process.env.CLOUDINARY_CLOUD_NAME,
api_key: process.env.CLOUDINARY_API_KEY,
api_secret: process.env.CLOUDINARY_SECRET,
});
/**
* Uploads file to Cloudinary CDN
*
* @param {stream} object, image streaming content
* @param {folder} string, folder name, where to save image
* @param {string} imagePublicId
*/
export const uploadToCloudinary = async (stream, folder, imagePublicId) => {
// if imagePublicId param is presented we should overwrite the image
const options = imagePublicId
? { public_id: imagePublicId, overwrite: true }
import moment from "moment"
import { Trip } from "./trip.model"
import { User } from "../user/user.model"
import { Waypoint } from "../waypoint/waypoint.model"
import cloudinary from "cloudinary"
cloudinary.config({
cloud_name: process.env.CLOUD_NAME,
api_key: process.env.CLOUDINARY_KEY,
api_secret: process.env.CLOUDINARY_SECRET_KEY
})
export const getAllTrips = (req, res) => {
Trip.find({})
.then(trips => {
res.status(200).json(trips)
})
.catch(err => {
res.status(500).send(err)
})
}
export const createTrip = async (req, res) => {
async setup({ config }) {
cloudinary.config(snakeCaseProps(config));
this.cloudinary = cloudinary;
this.uploader = [
'upload',
'rename',
'destroy',
'addTag',
'removeTag',
'removeAllTags',
'replaceTag',
].reduce(
(acc, method) => ({
...acc,
[method]: promisify(
this.cloudinary.v2.uploader[snakeCase(method)].bind(this.cloudinary.v2.uploader),
import cloudinary from 'cloudinary';
import { CLOUDINARY_CONFIG } from '~/env';
cloudinary.config(CLOUDINARY_CONFIG);
export default cloudinary;
function gulpCloudinary(config, tags) {
this.config = config;
this.tags = tags;
cloudinary.config(this.config);
}
constructor(options) {
super(options);
this.config = options || {};
cloudinary.config(options);
}