cloudinary-promised
Advanced tools
Comparing version
@@ -12,3 +12,2 @@ "use strict"; | ||
const cloudinary = require('cloudinary'); | ||
const util_1 = require("util"); | ||
const url_exists_promise_1 = require("url-exists-promise"); | ||
@@ -33,6 +32,12 @@ const videoExtensions = ['mp4']; | ||
}; | ||
const uploadPromised = util_1.promisify(cloudinary.v2.uploader.upload); | ||
exports.uploadFile = (id, localAbsolutePath, options) => uploadPromised(localAbsolutePath, Object.assign({ public_id: id, resource_type: exports.isVideo(localAbsolutePath) ? 'video' : 'image' }, options)); | ||
const uploadExplicitPromised = util_1.promisify(cloudinary.v2.uploader.explicit); | ||
exports.getMetadata = (id, localAbsolutePath, options) => uploadExplicitPromised(id, Object.assign({ image_metadata: true, type: 'upload', resource_type: exports.isVideo(localAbsolutePath) ? 'video' : 'image' }, options)); | ||
exports.uploadFile = (id, localAbsolutePath, options) => new Promise((resolve, reject) => cloudinary.v2.uploader.upload(localAbsolutePath, Object.assign({ public_id: id, resource_type: exports.isVideo(localAbsolutePath) ? 'video' : 'image' }, options), (error, result) => { | ||
if (error) | ||
return reject(error); | ||
resolve(result); | ||
})); | ||
exports.getMetadata = (id, localAbsolutePath, options) => new Promise((resolve, reject) => cloudinary.v2.uploader.explicit(id, Object.assign({ image_metadata: true, type: 'upload', resource_type: exports.isVideo(localAbsolutePath) ? 'video' : 'image' }, options), (error, result) => { | ||
if (error) | ||
return reject(error); | ||
resolve(result); | ||
})); | ||
exports.imageExists = (id, options) => { | ||
@@ -39,0 +44,0 @@ const urlImg = `http://res.cloudinary.com/${options.cloud_name}/image/upload/${id}`; |
{ | ||
"name": "cloudinary-promised", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"description": "Wrapper for Cloudinary functions.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
9555
3.72%77
8.45%