How to use the cloudinary.config function in cloudinary

To help you get started, we’ve selected a few cloudinary examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github BOOLRon / watchdog4cloudinary / index.js View on Github external
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)
github simov / express-admin-examples / config / custom / events / events.js View on Github external
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;
github ReactFinland / graphql-api / server / routes / resolve-image.ts View on Github external
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!");
github IAMOTZ / node-react-cloudinary / server / cloudinary.js View on Github external
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) => {
github DimiMikadze / create-social-network / api / utils / cloudinary.js View on Github external
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 }
github Lambda-School-Labs / LabsPT1_bkwds / server / src / api / resources / trip / trip.controller.js View on Github external
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) => {
github oors / oors / packages / oors-cloudinary / src / index.js View on Github external
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),
github Shyam-Chen / Express-Starter / src / core / cloudinary.js View on Github external
import cloudinary from 'cloudinary';

import { CLOUDINARY_CONFIG } from '~/env';

cloudinary.config(CLOUDINARY_CONFIG);

export default cloudinary;
github Shipow / searchstone / gulpfile.js View on Github external
function gulpCloudinary(config, tags) {
  this.config = config;
  this.tags = tags;
  cloudinary.config(this.config);
}
github smooth-code / blog / content / adapters / storage / cloudinary.js View on Github external
constructor(options) {
    super(options);
    this.config = options || {};
    cloudinary.config(options);
  }