New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cloudinary

Package Overview
Dependencies
Maintainers
1
Versions
116
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cloudinary - npm Package Compare versions

Comparing version 1.13.2 to 1.14.0

26

CHANGELOG.md
1.14.0 / 2019-03-26
===================
New functionality
-----------------
* Support format in transformation API
* Add support for `start_offset` value `auto`
* Add support for gs:// urls in uploader
* Add support for the `quality_analysis` upload parameter. Fixes #171
* Add `fps` transformation parameter (#230)
Other changes
-------------
* Update code samples in the README file. Fixes #135
* Reject deferred on request error. Fixes #136
* Refactor test code after conversion from CoffeeScript
* Convert test code from CoffeeScript to JavaScript
* Merge pull request #208 from cloudinary/fix_update_samples_readme
* Fix the "upload large" test for node 4
* Remove bower from the sample code
* Add timeout to search integration tests
* Fix detection test
* Fix broken links in node sample project readme
1.13.2 / 2018-11-14

@@ -3,0 +29,0 @@ ===================

40

lib-es5/api.js

@@ -22,2 +22,4 @@ 'use strict';

var TRANSFORMATIONS_URI = "transformations";
function call_api(method, uri, params, callback, options) {

@@ -121,5 +123,4 @@ var handle_response = void 0,

request.on("error", function (e) {
return typeof callback === "function" ? callback({
error: e
}) : void 0;
deferred.reject(e);
return typeof callback === "function" ? callback({ error: e }) : void 0;
});

@@ -392,3 +393,4 @@ request.setTimeout(ensureOption(options, "timeout", 60000));

return call_api("get", ["transformations"], only(options, "next_cursor", "max_results", "named"), callback, options);
var params = only(options, "next_cursor", "max_results", "named");
return call_api("get", TRANSFORMATIONS_URI, params, callback, options);
};

@@ -399,5 +401,5 @@

var uri = void 0;
uri = ["transformations", transformationString(transformation)];
return call_api("get", uri, only(options, "next_cursor", "max_results"), callback, options);
var params = only(options, "next_cursor", "max_results");
params.transformation = utils.build_eager(transformation);
return call_api("get", TRANSFORMATIONS_URI, params, callback, options);
};

@@ -408,5 +410,5 @@

var uri = void 0;
uri = ["transformations", transformationString(transformation)];
return call_api("delete", uri, {}, callback, options);
var params = {};
params.transformation = utils.build_eager(transformation);
return call_api("delete", TRANSFORMATIONS_URI, params, callback, options);
};

@@ -417,10 +419,8 @@

var params = void 0,
uri = void 0;
uri = ["transformations", transformationString(transformation)];
params = only(updates, "allowed_for_strict");
var params = only(updates, "allowed_for_strict");
params.transformation = utils.build_eager(transformation);
if (updates.unsafe_update != null) {
params.unsafe_update = transformationString(updates.unsafe_update);
params.unsafe_update = utils.build_eager(updates.unsafe_update);
}
return call_api("put", uri, params, callback, options);
return call_api("put", TRANSFORMATIONS_URI, params, callback, options);
};

@@ -431,7 +431,5 @@

var uri = void 0;
uri = ["transformations", name];
return call_api("post", uri, {
transformation: transformationString(definition)
}, callback, options);
var params = { name };
params.transformation = utils.build_eager(definition);
return call_api("post", TRANSFORMATIONS_URI, params, callback, options);
};

@@ -438,0 +436,0 @@

@@ -7,3 +7,3 @@ "use strict";

var PRELOADED_CLOUDINARY_PATH, PreloadedFile, config, utils;
var PRELOADED_CLOUDINARY_PATH, config, utils;

@@ -16,3 +16,3 @@ utils = require("./utils");

PreloadedFile = function () {
var PreloadedFile = function () {
function PreloadedFile(file_info) {

@@ -62,3 +62,3 @@ _classCallCheck(this, PreloadedFile);

value: function identifier() {
return "v" + this.version + "/" + this.filename;
return `v${this.version}/${this.filename}`;
}

@@ -68,3 +68,3 @@ }, {

value: function toString() {
return this.resource_type + "/" + this.type + "/v" + this.version + "/" + this.filename + "#" + this.signature;
return `${this.resource_type}/${this.type}/v${this.version}/${this.filename}#${this.signature}`;
}

@@ -74,11 +74,11 @@ }, {

value: function toJSON() {
var key, ref, result, val;
result = {};
ref = this;
for (key in ref) {
val = ref[key];
var _this = this;
var result = {};
Object.getOwnPropertyNames(this).forEach(function (key) {
var val = _this[key];
if (typeof val !== 'function') {
result[key] = val;
}
}
});
return result;

@@ -85,0 +85,0 @@ }

@@ -70,3 +70,3 @@ 'use strict';

var params = build_upload_params(options);
if (file != null && file.match(/^ftp:|^https?:|^s3:|^data:[^;]*;base64,([a-zA-Z0-9\/+\n=]+)$/)) {
if (file != null && file.match(/^ftp:|^https?:|^gs:|^s3:|^data:[^;]*;base64,([a-zA-Z0-9\/+\n=]+)$/)) {
return [params, { file: file }];

@@ -73,0 +73,0 @@ } else {

@@ -342,2 +342,3 @@ "use strict";

public_id: options.public_id,
quality_analysis: utils.as_safe_bool(options.quality_analysis),
responsive_breakpoints: utils.generate_responsive_breakpoints_string(options["responsive_breakpoints"]),

@@ -428,3 +429,5 @@ return_delete_token: utils.as_safe_bool(options.return_delete_token),

return utils.build_array(transformations).map(function (transformation) {
return [utils.generate_transformation_string(clone(transformation)), transformation.format].filter(utils.present).join('/');
var transformationString = utils.generate_transformation_string(clone(transformation));
var format = transformation.format;
return format == null ? transformationString : `${transformationString}/${format}`;
}).join('|');

@@ -458,6 +461,9 @@ };

var TRANSFORMATION_PARAMS = ['angle', 'aspect_ratio', 'audio_codec', 'audio_frequency', 'background', 'bit_rate', 'border', 'color', 'color_space', 'crop', 'default_image', 'delay', 'density', 'dpr', 'duration', 'effect', 'end_offset', 'fetch_format', 'flags', 'gravity', 'height', 'if', 'keyframe_interval', 'offset', 'opacity', 'overlay', 'page', 'prefix', 'quality', 'radius', 'raw_transformation', 'responsive_width', 'size', 'start_offset', 'streaming_profile', 'transformation', 'underlay', 'variables', 'video_codec', 'video_sampling', 'width', 'x', 'y', 'zoom' // + any key that starts with '$'
var TRANSFORMATION_PARAMS = ['angle', 'aspect_ratio', 'audio_codec', 'audio_frequency', 'background', 'bit_rate', 'border', 'color', 'color_space', 'crop', 'default_image', 'delay', 'density', 'dpr', 'duration', 'effect', 'end_offset', 'fetch_format', 'flags', 'fps', 'gravity', 'height', 'if', 'keyframe_interval', 'offset', 'opacity', 'overlay', 'page', 'prefix', 'quality', 'radius', 'raw_transformation', 'responsive_width', 'size', 'start_offset', 'streaming_profile', 'transformation', 'underlay', 'variables', 'video_codec', 'video_sampling', 'width', 'x', 'y', 'zoom' // + any key that starts with '$'
];
exports.generate_transformation_string = function generate_transformation_string(options) {
if (utils.isString(options)) {
return options;
}
if (isArray(options)) {

@@ -545,2 +551,6 @@ return options.map(function (t) {

var ifValue = process_if(utils.option_consume(options, "if"));
var fps = utils.option_consume(options, 'fps');
if (isArray(fps)) {
fps = fps.join('-');
}
var params = {

@@ -556,2 +566,3 @@ a: normalize_expression(angle),

fl: flags,
fps: fps,
h: normalize_expression(height),

@@ -558,0 +569,0 @@ ki: normalize_expression(utils.option_consume(options, "keyframe_interval")),

@@ -16,2 +16,4 @@

const TRANSFORMATIONS_URI = "transformations";
function call_api(method, uri, params, callback, options) {

@@ -113,5 +115,4 @@ let handle_response, query_params;

request.on("error", function (e) {
return typeof callback === "function" ? callback({
error: e
}) : void 0;
deferred.reject(e);
return typeof callback === "function" ? callback({error: e}) : void 0;
});

@@ -297,33 +298,31 @@ request.setTimeout( ensureOption(options, "timeout", 60000));

exports.transformations = function transformations(callback, options={}) {
return call_api("get", ["transformations"], only(options, "next_cursor", "max_results", "named"), callback, options);
const params = only(options, "next_cursor", "max_results", "named");
return call_api("get", TRANSFORMATIONS_URI, params, callback, options);
};
exports.transformation = function transformation(transformation, callback, options={}) {
let uri;
uri = ["transformations", transformationString(transformation)];
return call_api("get", uri, only(options, "next_cursor", "max_results"), callback, options);
const params = only(options, "next_cursor", "max_results");
params.transformation = utils.build_eager(transformation);
return call_api("get", TRANSFORMATIONS_URI, params, callback, options);
};
exports.delete_transformation = function delete_transformation(transformation, callback, options={}) {
let uri;
uri = ["transformations", transformationString(transformation)];
return call_api("delete", uri, {}, callback, options);
const params = {};
params.transformation = utils.build_eager(transformation);
return call_api("delete", TRANSFORMATIONS_URI, params, callback, options);
};
exports.update_transformation = function update_transformation(transformation, updates, callback, options={}) {
let params, uri;
uri = ["transformations", transformationString(transformation)];
params = only(updates, "allowed_for_strict");
const params = only(updates, "allowed_for_strict");
params.transformation = utils.build_eager(transformation);
if (updates.unsafe_update != null) {
params.unsafe_update = transformationString(updates.unsafe_update);
params.unsafe_update = utils.build_eager(updates.unsafe_update);
}
return call_api("put", uri, params, callback, options);
return call_api("put", TRANSFORMATIONS_URI, params, callback, options);
};
exports.create_transformation = function create_transformation(name, definition, callback, options={}) {
let uri;
uri = ["transformations", name];
return call_api("post", uri, {
transformation: transformationString(definition)
}, callback, options);
const params = {name};
params.transformation = utils.build_eager(definition);
return call_api("post", TRANSFORMATIONS_URI, params, callback, options);
};

@@ -330,0 +329,0 @@

@@ -1,2 +0,2 @@

var PRELOADED_CLOUDINARY_PATH, PreloadedFile, config, utils;
var PRELOADED_CLOUDINARY_PATH, config, utils;

@@ -9,3 +9,3 @@ utils = require("./utils");

PreloadedFile = class PreloadedFile {
class PreloadedFile {
constructor(file_info) {

@@ -49,24 +49,22 @@ var matches, public_id_and_format;

identifier() {
return "v" + this.version + "/" + this.filename;
return `v${this.version}/${this.filename}`;
}
toString() {
return this.resource_type + "/" + this.type + "/v" + this.version + "/" + this.filename + "#" + this.signature;
return `${this.resource_type}/${this.type}/v${this.version}/${this.filename}#${this.signature}`;
}
toJSON() {
var key, ref, result, val;
result = {};
ref = this;
for (key in ref) {
val = ref[key];
var result = {};
Object.getOwnPropertyNames(this).forEach((key) => {
let val = this[key];
if (typeof val !== 'function') {
result[key] = val;
}
}
});
return result;
}
};
}
module.exports = PreloadedFile;

@@ -42,3 +42,3 @@ const {upload_prefix} = require("./config");

let params = build_upload_params(options);
if ((file != null) && file.match(/^ftp:|^https?:|^s3:|^data:[^;]*;base64,([a-zA-Z0-9\/+\n=]+)$/)) {
if ((file != null) && file.match(/^ftp:|^https?:|^gs:|^s3:|^data:[^;]*;base64,([a-zA-Z0-9\/+\n=]+)$/)) {
return [params, {file: file}];

@@ -45,0 +45,0 @@ } else {

@@ -339,2 +339,3 @@ /**

public_id: options.public_id,
quality_analysis: utils.as_safe_bool(options.quality_analysis),
responsive_breakpoints: utils.generate_responsive_breakpoints_string(options["responsive_breakpoints"]),

@@ -412,8 +413,9 @@ return_delete_token: utils.as_safe_bool(options.return_delete_token),

exports.build_eager = function build_eager(transformations) {
return utils.build_array(transformations).map(
transformation => [
utils.generate_transformation_string(clone(transformation)),
transformation.format
].filter(utils.present).join('/')
).join('|');
return utils.build_array(transformations)
.map(transformation => {
const transformationString = utils.generate_transformation_string(clone(transformation));
const format = transformation.format;
return format == null ? transformationString : `${transformationString}/${format}`;
}
).join('|');
};

@@ -460,2 +462,3 @@

'flags',
'fps',
'gravity',

@@ -489,2 +492,5 @@ 'height',

exports.generate_transformation_string = function generate_transformation_string(options) {
if(utils.isString(options)) {
return options;
}
if (isArray(options)) {

@@ -553,2 +559,6 @@ return options.map(t=>utils.generate_transformation_string(clone(t))).filter(utils.present).join('/');

let ifValue = process_if(utils.option_consume(options, "if"));
let fps = utils.option_consume(options, 'fps');
if(isArray(fps)){
fps = fps.join('-');
}
let params = {

@@ -564,2 +574,3 @@ a: normalize_expression(angle),

fl: flags,
fps: fps,
h: normalize_expression(height),

@@ -566,0 +577,0 @@ ki: normalize_expression(utils.option_consume(options, "keyframe_interval")),

@@ -5,3 +5,3 @@ {

"description": "Cloudinary NPM for node.js integration",
"version": "1.13.2",
"version": "1.14.0",
"homepage": "http://cloudinary.com",

@@ -27,3 +27,2 @@ "license": "MIT",

"babel-runtime": "^6.26.0",
"coffee-script": "^1.12.7",
"dotenv": "4.x",

@@ -36,3 +35,4 @@ "expect.js": "0.3.x",

"nyc": "^13.0.1",
"sinon": "^6.1.4"
"sinon": "^6.1.4",
"webpack-cli": "^3.2.1"
},

@@ -39,0 +39,0 @@ "scripts": {

@@ -66,10 +66,16 @@ Cloudinary

### Require the Cloudinary library
```js
var cloudinary = require('cloudinary').v2
```
### Overriding the request agent
To override the request agent pass the agent into any method that makes a
request and it will be used instead of the normal https agent. e.g
```js
cloudinary.uploader.upload_stream(
function(result) { console.log(result); },
{ agent: myAgent }
{ agent: myAgent },
function(error, result) { console.log(result); }
);

@@ -85,7 +91,11 @@

cloudinary.url("sample.jpg", {width: 100, height: 150, crop: "fill"})
```js
cloudinary.url("sample.jpg", {width: 100, height: 150, crop: "fill"})
```
Another example, emedding a smaller version of an uploaded image while generating a 90x90 face detection based thumbnail:
cloudinary.url("woman.jpg", {width: 90, height: 90, crop: "thumb", gravity: "face"})
```js
cloudinary.url("woman.jpg", {width: 90, height: 90, crop: "thumb", gravity: "face"});
```

@@ -96,7 +106,11 @@ You can provide either a Facebook name or a numeric ID of a Facebook profile or a fan page.

cloudinary.url("billclinton.jpg", {width: 90, height: 130, type: "facebook", crop: "fill", gravity: "north_west"})
```js
cloudinary.url("billclinton.jpg", {width: 90, height: 130, type: "facebook", crop: "fill", gravity: "north_west"});
```
Same goes for Twitter:
cloudinary.url("billclinton.jpg", {type: "twitter_name"})
```js
cloudinary.url("billclinton.jpg", {type: "twitter_name"});
```

@@ -111,32 +125,47 @@ ![](https://res.cloudinary.com/cloudinary/image/upload/see_more_bullet.png) **See [our documentation](https://cloudinary.com/documentation/node_image_manipulation) for more information about displaying and transforming images in Node.js**.

var cloudinary = require('cloudinary')
```js
var cloudinary = require('cloudinary').v2;
cloudinary.uploader.upload("my_picture.jpg", function(error, result) { console.log(result) });
```
cloudinary.uploader.upload("my_picture.jpg", function(result) { console.log(result) })
Below is an example of an upload's result:
{ public_id: '4srvcynxrf5j87niqcx6w',
version: 1340625837,
signature: '01234567890abcdef01234567890abcdef012345',
width: 200,
height: 200,
format: 'jpg',
resource_type: 'image',
url: 'http://res.cloudinary.com/demo/image/upload/v1340625837/4srvcynxrf5j87niqcx6w.jpg',
secure_url: 'https://res.cloudinary.com/demo/image/upload/v1340625837/4srvcynxrf5j87niqcx6w.jpg' }
```json
{
"public_id": "4srvcynxrf5j87niqcx6w",
"version": 1340625837,
"signature": "01234567890abcdef01234567890abcdef012345",
"width": 200,
"height": 200,
"format": "jpg",
"resource_type": "image",
"url": "http://res.cloudinary.com/demo/image/upload/v1340625837/4srvcynxrf5j87niqcx6w.jpg",
"secure_url": "https://res.cloudinary.com/demo/image/upload/v1340625837/4srvcynxrf5j87niqcx6w.jpg"
}
```
The uploaded image is assigned a randomly generated public ID. The image is immediately available for download through a CDN:
cloudinary.url("abcfrmo8zul1mafopawefg.jpg")
```js
cloudinary.url("abcfrmo8zul1mafopawefg.jpg");
http://res.cloudinary.com/demo/image/upload/abcfrmo8zul1mafopawefg.jpg
// http://res.cloudinary.com/demo/image/upload/abcfrmo8zul1mafopawefg.jpg
```
You can also specify your own public ID:
cloudinary.uploader.upload("http://www.example.com/image.jpg", function(result) { console.log(result) }, {public_id: 'sample_remote'})
```js
cloudinary.uploader.upload(
"http://www.example.com/image.jpg",
{public_id: 'sample_remote'},
function(error, result) {
console.log(result)
}
);
cloudinary.url("sample_remote.jpg")
cloudinary.url("sample_remote.jpg")
http://res.cloudinary.com/demo/image/upload/sample_remote.jpg
// http://res.cloudinary.com/demo/image/upload/sample_remote.jpg
```
![](https://res.cloudinary.com/cloudinary/image/upload/see_more_bullet.png) **See [our documentation](https://cloudinary.com/documentation/node_image_upload) for plenty more options of uploading to the cloud from your Node.js code or directly from the browser**.

@@ -148,5 +177,7 @@

var fs = require('fs');
var stream = cloudinary.uploader.upload_stream(function(result) { console.log(result); });
var file_reader = fs.createReadStream('my_picture.jpg', {encoding: 'binary'}).on('data', stream.write).on('end', stream.end);
```js
var fs = require('fs');
var stream = cloudinary.uploader.upload_stream(function(error, result) { console.log(result); });
var file_reader = fs.createReadStream('my_picture.jpg', {encoding: 'binary'}).on('data', stream.write).on('end', stream.end);
```

@@ -156,9 +187,13 @@ #### Version 1.1 upload_stream change notes

var file_reader = fs.createReadStream('my_picture.jpg').pipe(stream);
```js
var file_reader = fs.createReadStream('my_picture.jpg').pipe(stream);
```
if you still need to use event chanining, you can wrap `stream.write` and `stream.end` with wrapper functions
var file_reader = fs.createReadStream('my_picture.jpg', {encoding: 'binary'}).
on('data', function(data){stream.write(data)}).on('end', function(){stream.end()});
```js
var file_reader = fs.createReadStream('my_picture.jpg', {encoding: 'binary'})
.on('data', function(data){stream.write(data)})
.on('end', function(){stream.end()});
```
### cloudinary.image

@@ -170,5 +205,7 @@

cloudinary.image("sample", {format: "png", width: 100, height: 100, crop: "fill"})
```js
cloudinary.image("sample", {format: "png", width: 100, height: 100, crop: "fill"})
// <img src='http://res.cloudinary.com/demo/image/upload/c_fill,h_100,w_100/sample.png' height='100' width='100'/>
// <img src='http://res.cloudinary.com/demo/image/upload/c_fill,h_100,w_100/sample.png' height='100' width='100'/>
```

@@ -175,0 +212,0 @@ ### Samples

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc