mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-23 10:53:34 +03:00
25 lines
697 B
JavaScript
25 lines
697 B
JavaScript
const fileUploadResponse = function (db, {requestBody}) {
|
|
// let [ref] = requestBody.getAll('ref');
|
|
let [purpose] = requestBody.getAll('purpose');
|
|
let [file] = requestBody.getAll('file');
|
|
let now = new Date();
|
|
let year = now.getFullYear();
|
|
let month = `${now.getMonth()}`;
|
|
|
|
if (month.length === 1) {
|
|
month = `0${month}`;
|
|
}
|
|
|
|
if (['image', 'profile_image', 'icon'].includes(purpose)) {
|
|
return {
|
|
images: [{
|
|
url: `/content/images/${year}/${month}/${file.name}`
|
|
}]
|
|
};
|
|
}
|
|
};
|
|
|
|
export default function mockUploads(server) {
|
|
server.post('/images/upload/', fileUploadResponse, 200, {timing: 100});
|
|
}
|