fix: metadata not update
This commit is contained in:
parent
a7f012bda2
commit
0202e0e0f8
2 changed files with 15 additions and 8 deletions
|
|
@ -270,9 +270,11 @@ export class FileController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบไฟล์");
|
||||
}
|
||||
|
||||
const { file, ...metadata } = body;
|
||||
|
||||
// assume user will probably replace file by re-upload but maybe just rename
|
||||
if (body.file) {
|
||||
const destination = `${basePath}${replaceIllegalChars(body.file)}`;
|
||||
if (file) {
|
||||
const destination = `${basePath}${replaceIllegalChars(file)}`;
|
||||
const source = `/${DEFAULT_BUCKET}/${basePath}${fileName}`;
|
||||
const copy = await minioClient.copyObject(DEFAULT_BUCKET!, destination, source, copyCond);
|
||||
|
||||
|
|
@ -291,9 +293,10 @@ export class FileController extends Controller {
|
|||
index,
|
||||
id,
|
||||
doc: {
|
||||
...metadata,
|
||||
pathname: destination,
|
||||
path: basePath,
|
||||
fileName: replaceIllegalChars(body.file),
|
||||
fileName: replaceIllegalChars(file),
|
||||
updatedAt: new Date().toISOString(),
|
||||
updatedBy: request.user.preferred_username ?? "n/a",
|
||||
},
|
||||
|
|
@ -318,7 +321,7 @@ export class FileController extends Controller {
|
|||
index,
|
||||
id,
|
||||
doc: {
|
||||
...body,
|
||||
...metadata,
|
||||
updatedAt: new Date().toISOString(),
|
||||
updatedBy: request.user.preferred_username ?? "n/a",
|
||||
},
|
||||
|
|
|
|||
|
|
@ -277,9 +277,11 @@ export class SubFolderFileController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบไฟล์");
|
||||
}
|
||||
|
||||
const { file, ...metadata } = body;
|
||||
|
||||
// assume user will probably replace file by re-upload but maybe just rename
|
||||
if (body.file) {
|
||||
const destination = `${basePath}${replaceIllegalChars(body.file)}`;
|
||||
if (file) {
|
||||
const destination = `${basePath}${replaceIllegalChars(file)}`;
|
||||
const source = `/${DEFAULT_BUCKET}/${basePath}${fileName}`;
|
||||
const copy = await minioClient.copyObject(DEFAULT_BUCKET!, destination, source, copyCond);
|
||||
|
||||
|
|
@ -298,8 +300,10 @@ export class SubFolderFileController extends Controller {
|
|||
index,
|
||||
id,
|
||||
doc: {
|
||||
...metadata,
|
||||
pathname: destination,
|
||||
fileName: replaceIllegalChars(body.file),
|
||||
path: basePath,
|
||||
fileName: replaceIllegalChars(file),
|
||||
updatedAt: new Date().toISOString(),
|
||||
updatedBy: request.user.preferred_username ?? "n/a",
|
||||
},
|
||||
|
|
@ -324,7 +328,7 @@ export class SubFolderFileController extends Controller {
|
|||
index,
|
||||
id,
|
||||
doc: {
|
||||
...body,
|
||||
...metadata,
|
||||
updatedAt: new Date().toISOString(),
|
||||
updatedBy: request.user.preferred_username ?? "n/a",
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue