2019-07-28 03:23:51 +00:00
|
|
|
import http from '@/api/http';
|
2020-07-11 20:38:49 +00:00
|
|
|
import { rawDataToFileObject } from '@/api/transformers';
|
2019-07-28 03:23:51 +00:00
|
|
|
|
|
|
|
export interface FileObject {
|
2020-08-02 01:48:58 +00:00
|
|
|
key: string;
|
2019-07-28 03:23:51 +00:00
|
|
|
name: string;
|
|
|
|
mode: string;
|
2022-06-26 19:13:52 +00:00
|
|
|
modeBits: string;
|
2019-07-28 03:23:51 +00:00
|
|
|
size: number;
|
|
|
|
isFile: boolean;
|
|
|
|
isSymlink: boolean;
|
|
|
|
mimetype: string;
|
|
|
|
createdAt: Date;
|
|
|
|
modifiedAt: Date;
|
2020-07-15 04:16:49 +00:00
|
|
|
isArchiveType: () => boolean;
|
2020-08-30 17:25:48 +00:00
|
|
|
isEditable: () => boolean;
|
2019-07-28 03:23:51 +00:00
|
|
|
}
|
|
|
|
|
2020-07-11 05:10:51 +00:00
|
|
|
export default async (uuid: string, directory?: string): Promise<FileObject[]> => {
|
|
|
|
const { data } = await http.get(`/api/client/servers/${uuid}/files/list`, {
|
2020-12-17 05:38:46 +00:00
|
|
|
params: { directory: directory ?? '/' },
|
2019-07-28 03:23:51 +00:00
|
|
|
});
|
2020-07-11 05:10:51 +00:00
|
|
|
|
2020-07-11 20:38:49 +00:00
|
|
|
return (data.data || []).map(rawDataToFileObject);
|
2019-07-28 03:23:51 +00:00
|
|
|
};
|