mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-17 13:53:45 +02:00
Add endpoint support for decompressing files
This commit is contained in:
8
resources/scripts/api/server/files/decompressFiles.ts
Normal file
8
resources/scripts/api/server/files/decompressFiles.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import http from '@/api/http';
|
||||
|
||||
export default async (uuid: string, directory: string, file: string): Promise<void> => {
|
||||
await http.post(`/api/client/servers/${uuid}/files/decompress`, { root: directory, file }, {
|
||||
timeout: 300000,
|
||||
timeoutErrorMessage: 'It looks like this archive is taking a long time to be unarchived. Once completed the unarchived files will appear.',
|
||||
});
|
||||
};
|
||||
@@ -12,6 +12,7 @@ export interface FileObject {
|
||||
mimetype: string;
|
||||
createdAt: Date;
|
||||
modifiedAt: Date;
|
||||
isArchiveType: () => boolean;
|
||||
}
|
||||
|
||||
export default async (uuid: string, directory?: string): Promise<FileObject[]> => {
|
||||
|
||||
@@ -23,4 +23,12 @@ export const rawDataToFileObject = (data: FractalResponseData): FileObject => ({
|
||||
mimetype: data.attributes.mimetype,
|
||||
createdAt: new Date(data.attributes.created_at),
|
||||
modifiedAt: new Date(data.attributes.modified_at),
|
||||
|
||||
isArchiveType: function () {
|
||||
return this.isFile && [
|
||||
'application/zip',
|
||||
'application/gzip',
|
||||
'application/x-tar',
|
||||
].indexOf(this.mimetype) >= 0;
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user