How to use the cloudinary.v2.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 ireade / caniuse-embed / functions / screenshot / screenshot.js View on Github external
.then((res) => res.arrayBuffer())
			.then(arrayBufferToBuffer)
			.then((res) => resolve(res))
			.catch((err) => {
				console.log("error trimming screenshot");
				console.log(err);
				resolve(screenshot);
			});
	});
};


/* Upload Screenshot with Cloudinary *********************** */

const cloudinary = require('cloudinary').v2;
cloudinary.config({
	cloud_name: process.env.CLOUDINARY_CLOUD_NAME,
	api_key: process.env.CLOUDINARY_API_KEY,
	api_secret: process.env.CLOUDINARY_API_SECRET
});

const uploadScreenshot = (feature, screenshot) => {
	return new Promise((resolve, reject) => {

		const options = {
			folder: 'caniuse-embed/static',
			public_id: `${feature}-${new Date().getTime()}`
		};

		cloudinary.uploader.upload_stream(options, (error, result) => {
			if (error) reject(error)
			else resolve(result);
github cloudinary / cloudinary_npm / samples / photo_album / controllers / photos_controller.js View on Github external
function add_direct_unsigned(req, res) {
  // Configuring cloudinary_cors direct upload to support old IE versions
  var cloudinary_cors = "http://" + req.headers.host + "/cloudinary_cors.html";

  // Set a unique unsigned upload preset name (for demo purposes only).
  // In 'real life' scenario the preset name will be meaningful and will be set
  // via online console or API not related to the actual upload
  var sha1 = crypto.createHash('sha1');
  sha1.update(cloudinary.config('api_key') + cloudinary.config('api_secret'));
  var preset_name = "sample_" + sha1.digest('hex');

  // Create a new photo model and set it's default title
  var photo = new Photo();
  Photo.count().then(function (amount) {
    photo.title = "My Photo #" + (amount + 1) + " (direct unsigned)";
  })
    .then(function () {
      return cloudinary.api.upload_preset(preset_name);
    })
    .then(function (preset) {
      if (!preset.settings.return_delete_token) {
        return cloudinary.api.update_upload_preset(preset_name, { return_delete_token: true });
      }
      return undefined;
    })
github eexit / ghost-storage-cloudinary / index.js View on Github external
constructor(options) {
        super(options);

        const config = options || {},
            auth = config.auth || config,
            // Kept to avoid a BCB with 2.x versions
            legacy = config.configuration || {};

        this.useDatedFolder = config.useDatedFolder || false;
        this.uploadOptions = config.upload || legacy.file || {};
        this.fetchOptions = config.fetch || legacy.image || {};
        this.rjsOptions = config.rjs || null;

        cloudinary.config(auth);
    }
github Atyantik / react-pwa / cloudinary.js View on Github external
const cloudinary = require('cloudinary').v2;
const fs = require('fs');
const path = require('path');

cloudinary.config({
  cloud_name: process.env.CLOUDINARY_CLOUD_NAME,
  api_key: process.env.CLOUDINARY_API_KEY,
  api_secret: process.env.CLOUDINARY_API_SECRET,
});

const walkSync = (dir, fileList = [], rootDir = '') => {
  const files = fs.readdirSync(dir);
  files.forEach((file) => {
    if (fs.statSync(`${dir}/${file}`).isDirectory()) {
      // eslint-disable-next-line
      fileList = walkSync(dir + '/' + file, fileList, rootDir);
    } else {
      fileList.push(`${dir}/${file}`.replace(rootDir, ''));
    }
  });
  return fileList;
github IsenrichO / react-timeline / server.js View on Github external
const dedent = require('dedent');
const dotenv = require('dotenv').config();
const Cloudinary = require('cloudinary').v2;
const App = require('./server/app.js');

Cloudinary.config({
  api_key: process.env.API_KEY,
  api_secret: process.env.API_SECRET,
  cloud_name: process.env.CLOUD_NAME,
});

App.get('*', (req, res) => {
  res.redirect('/');
});

const Server = App.listen(process.env.PORT || 3000, () => {
  const serverPort = Server.address().port;
  console.info(dedent(`
    ============================================================
    Server is up and running on LocalHost at Port ${serverPort}:
                < http://localhost:${serverPort}/ >
    ============================================================
github ireade / caniuse-embed / functions / screenshot / upload-screenshot.js View on Github external
const cloudinary = require('cloudinary').v2;

if (process.env.CLOUDINARY_CLOUD_NAME) {
  cloudinary.config(require("./cloudinary-config"));
} else {
  cloudinary.config(require("./cloudinary-config.secrets"));
}

module.exports = (feature, screenshot) => {
  return new Promise((resolve, reject) => {

    const today = new Date();
    const dd = today.getDate();
    const mm = today.getMonth() + 1;
    const yyyy = today.getFullYear();
    const date = `${yyyy}-${mm}-${dd}`;

    const options = {
      folder: 'caniuse-embed',
      public_id: `${feature}-${date}`
github ireade / caniuse-embed-screenshot-api / modules / upload-screenshot.js View on Github external
const cloudinary = require('cloudinary').v2;

if (process.env.CLOUDINARY_CLOUD_NAME) {
  cloudinary.config(require("../cloudinary-config"));
} else {
  cloudinary.config(require("../cloudinary-config.secrets"));
}

module.exports = (feature, screenshot, options) => {
  return new Promise((resolve, reject) => {

    options = options || {
      folder: 'caniuse-embed',
      public_id: `${feature}-${new Date().getTime()}`
    };

    cloudinary.uploader.upload_stream(options, (error, result) => {
      if (error) reject(error)
      else resolve(result);
    }).end(screenshot);
  });
}
github cloudinary-devs / gatsby-transformer-cloudinary / packages / gatsby-transformer-cloudinary / upload.js View on Github external
exports.uploadImageNodeToCloudinary = async (node, options) => {
  cloudinary.config({
    cloud_name: options.cloudName,
    api_key: options.apiKey,
    api_secret: options.apiSecret,
  });

  const result = await cloudinary.uploader.upload(node.absolutePath, {
    folder: options.uploadFolder,
    public_id: node.name,
    responsive_breakpoints: [
      {
        create_derived: true,
        bytes_step: 20000,
        min_width: DEFAULT_FLUID_MIN_WIDTH,
        max_width: DEFAULT_FLUID_MAX_WIDTH,
        max_images: 20,
      },
github strapi / strapi / packages / strapi-provider-upload-cloudinary / lib / index.js View on Github external
init: config => {
    cloudinary.config({
      cloud_name: config.cloud_name,
      api_key: config.api_key,
      api_secret: config.api_secret,
    });

    return {
      upload(file) {
        return new Promise((resolve, reject) => {
          const upload_stream = cloudinary.uploader.upload_stream(
            { resource_type: 'auto' },
            (err, image) => {
              if (err) {
                return reject(err);
              }
              file.public_id = image.public_id;
              file.url = image.secure_url;