1
0
Fork 0
mirror of https://github.com/TryGhost/Ghost-Admin.git synced 2023-12-14 02:33:04 +01:00
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});
}