mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 22:43:30 +03:00
4237446277
no issue - Consistent naming for postLookup - makes it easier to search and inspect the various usages - Cleanup unneeded code - Make res.render calls more consistent - add some consistency to the calls to res.render - Remove ancient reference to dataProvider - Let's call it models everywhere now... - Use consistent formatting across the API - we're no longer using alignment in vars - Misc other consistency changes in API - always refer to local utils as apiUtils - logical grouping of requires - dependencies, utils, "lib common" etc - use xAPI to refer to API endpoints, e.g. mailAPI, settingsAPI for clarity
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;
|