mirror of
https://github.com/directus/directus.git
synced 2026-02-18 00:01:20 -05:00
Default to filename without ext
This commit is contained in:
@@ -5,6 +5,7 @@ import sanitizeQuery from '../middleware/sanitize-query';
|
||||
import * as FilesService from '../services/files';
|
||||
import useCollection from '../middleware/use-collection';
|
||||
import { Item } from '../types';
|
||||
import path from 'path';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
@@ -46,6 +47,10 @@ const multipartHandler = (operation: 'create' | 'update') =>
|
||||
payload.storage = disk;
|
||||
}
|
||||
|
||||
if (!payload.title) {
|
||||
payload.title = path.parse(filename).name;
|
||||
}
|
||||
|
||||
if (req.accountability?.user) {
|
||||
payload.uploaded_by = req.accountability.user;
|
||||
}
|
||||
@@ -139,7 +144,6 @@ router.patch(
|
||||
return multipartHandler('update')(req, res, next);
|
||||
} else {
|
||||
const pk = await FilesService.updateFile(req.params.pk, req.body, req.accountability);
|
||||
|
||||
const file = await FilesService.readFile(pk, req.sanitizedQuery, req.accountability);
|
||||
|
||||
return res.status(200).json({ data: file || null });
|
||||
|
||||
@@ -68,10 +68,6 @@ export const createFile = async (
|
||||
});
|
||||
}
|
||||
|
||||
if (!payload.title) {
|
||||
payload.title = payload.id;
|
||||
}
|
||||
|
||||
await storage.disk(data.storage).put(payload.filename_disk, stream.pipe(pipeline));
|
||||
await itemsService.update(payload, pk);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user