Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
new Promise((yay, nay) => {
cloudinary.api.resources(
(result) => {
if (result.error) {
return nay(result.error);
}
// Aktuelle Bilder an Ausgabe-Array anhängen (max 500)
const results =
result.resources && result.resources.length
? images.concat(result.resources.map(transform))
: [];
// Falls noch weitere Bilder in Mediathek sind, diese auch laden
if (result.next_cursor) {
console.error('WARNING, MORE THAN 500 IMAGES!');
return getImages(config, results, result.next_cursor).then(yay);
}
submitForm(parser, form, function (err, req) {
expect(req.file).to.not.be.ok;
expect(err.code).to.equal('LIMIT_UNEXPECTED_FILE');
expect(err.field).to.equal('incorrect');
cloudinary.api.resources(function (res) {
expect(res).to.be.ok;
expect(res.resources).to.have.length(0);
done();
}, {
type: 'upload',
prefix: folder + '/'
});
});
});
afterEach(function (done) {
this.timeout(10000);
cloudinary.api.delete_resources_by_prefix(folder + '/', () => {
done();
});
});
autocomplete: function(req, res) {
var max = req.query.max || 10;
var prefix = req.query.prefix || '';
var next = req.query.next || null;
cloudinary.api.resources(function(result) {
if (result.error) {
res.json({ error: { message: result.error.message } });
} else {
res.json({
next: result.next_cursor,
items: result.resources
});
}
}, {
type: 'upload',
prefix: prefix,
max_results: max,
next_cursor: next
});
},
function initImageRegistry() {
cloudinary.api.resources(
result => {
if (!result.resources) {
throw new Error("No image resources!");
}
resources = result.resources.map(resource => ({
id: resource.public_id,
url: resource.secure_url,
}));
},
{
max_results: 500,
}
);
}
new Promise(yay =>
cloudinary.api.resource(
id,
(result) => {
yay(result);
},
Object.assign({}, config, {
tags: true,
context: true,
type: 'upload',
colors: true,
pages: true,
prefix: APP && APP !== 'gzk' ? `${APP}/` : '',
}),
),
).then(transform);
return new Promise(function (yay) {
return cloudinary.api.resource(id, function (result) {
yay(result);
}, Object.assign({}, config, {
tags: true,
context: true,
type: 'upload',
colors: true,
pages: true,
prefix: APP && APP !== 'gzk' ? APP + '/' : ''
}));
}).then(transform);
};
get: function(req, res) {
cloudinary.api.resource(req.query.id, function(result) {
if (result.error) {
res.json({ error: { message: result.error.message } });
} else {
res.json({ item: result });
}
});
}
};
return new Promise(function (yay) {
cloudinary.api.update(id, function (result) {
return yay(result);
}, Object.assign({}, config, {
prefix: APP ? APP + '/' : '',
tags: (tags || []).join(','),
context: context.join('|')
}));
}).then(transform);
};