1
0
mirror of https://github.com/TryGhost/Ghost.git synced 2024-12-29 13:52:10 +03:00
Ghost/ghost/admin/mirage/config/uploads.js

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});
}