fix: get list of file under folder return all file in subfolder

This commit is contained in:
Methapon2001 2023-11-28 16:27:49 +07:00
parent 93f0ac3431
commit 046b915fc3
No known key found for this signature in database
GPG key ID: 849924FEF46BD132
6 changed files with 234 additions and 7 deletions

View file

@ -43,8 +43,8 @@ export class FileController extends Controller {
const search = await esClient.search<StorageFile & { attachment: Record<string, string> }>({
index: DEFAULT_INDEX!,
query: {
prefix: {
pathname: `${cabinetName}/${drawerName}/${folderName}/`,
match: {
path: `${cabinetName}/${drawerName}/${folderName}/`,
},
},
size: 10000,
@ -115,6 +115,7 @@ export class FileController extends Controller {
const metadata: Partial<StorageFile> = {
pathname,
path: basePath,
fileName: body.file,
fileSize: 0,
fileType: "",
@ -201,6 +202,7 @@ export class FileController extends Controller {
id,
doc: {
pathname: destination,
path: basePath,
fileName: body.file,
updatedAt: new Date().toISOString(),
updatedBy: request.user.preferred_username ?? "n/a",

View file

@ -46,8 +46,8 @@ export class SubFolderFileController extends Controller {
const search = await esClient.search<StorageFile & { attachment: Record<string, string> }>({
index: DEFAULT_INDEX!,
query: {
prefix: {
pathname: `${cabinetName}/${drawerName}/${folderName}/${subFolderName}`,
match: {
path: `${cabinetName}/${drawerName}/${folderName}/${subFolderName}/`,
},
},
size: 10000,
@ -119,6 +119,7 @@ export class SubFolderFileController extends Controller {
const metadata: Partial<StorageFile> = {
pathname,
path: basePath,
fileName: body.file,
fileSize: 0,
fileType: "",