feat: return `.ext` to user if header is set

master
Sylvie 11 months ago
parent 92a37a4349
commit a6f2a0a9d0
No known key found for this signature in database
GPG Key ID: 75AB0FE5B983A3AF

@ -121,8 +121,12 @@ router.post('/', (req: Request, res: Response, next: Function) => {
const uploader = findFromToken(req.token)?.username ?? 'Unknown'; const uploader = findFromToken(req.token)?.username ?? 'Unknown';
log.success('File uploaded', logInfo, `uploaded by ${uploader}`); log.success('File uploaded', logInfo, `uploaded by ${uploader}`);
// ! random thing for 0.14.8 to append the file extension to the resource url
const extAppend = !(req.headers['x-ass-with-file-ext']?.toString() ?? false) ? ''
: `.${req.file.originalname.split('.').pop()}`;
// Build the URLs // Build the URLs
const resourceUrl = `${getTrueHttp()}${trueDomain}/${resourceId}`; const resourceUrl = `${getTrueHttp()}${trueDomain}/${resourceId}${extAppend}`;
const thumbnailUrl = `${getTrueHttp()}${trueDomain}/${resourceId}/thumbnail`; const thumbnailUrl = `${getTrueHttp()}${trueDomain}/${resourceId}/thumbnail`;
const deleteUrl = `${getTrueHttp()}${trueDomain}/${resourceId}/delete/${req.file.deleteId}`; const deleteUrl = `${getTrueHttp()}${trueDomain}/${resourceId}/delete/${req.file.deleteId}`;

Loading…
Cancel
Save