mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-19 00:11:49 +03:00
6f6c8f4521
refs #9178 - avoid importing 4 modules (logging, errors, events and i18n) - simply require common in each file
32 lines
713 B
JavaScript
32 lines
713 B
JavaScript
var Promise = require('bluebird'),
|
|
fs = require('fs-extra'),
|
|
pUnlink = Promise.promisify(fs.unlink),
|
|
storage = require('../adapters/storage'),
|
|
upload;
|
|
|
|
/**
|
|
* ## Upload API Methods
|
|
*
|
|
* **See:** [API Methods](index.js.html#api%20methods)
|
|
*/
|
|
upload = {
|
|
|
|
/**
|
|
* ### Add Image
|
|
*
|
|
* @public
|
|
* @param {{context}} options
|
|
* @returns {Promise<String>} location of uploaded file
|
|
*/
|
|
add: Promise.method(function (options) {
|
|
var store = storage.getStorage();
|
|
|
|
return store.save(options).finally(function () {
|
|
// Remove uploaded file from tmp location
|
|
return pUnlink(options.path);
|
|
});
|
|
})
|
|
};
|
|
|
|
module.exports = upload;
|