Ghost/core/server/api/upload.js
Hannah Wolfe 4237446277 Misc cleanup & consistency amends (#9002)
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
2017-09-12 17:31:14 +02:00

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;