filemanager: Integrate download and extract logic
This commit is contained in:
@@ -84,6 +84,14 @@ export function createDirectoryModel(origin, accessToken, api) {
|
||||
.send({ action: 'chown', uid: uid, recursive: true })
|
||||
.query({ access_token: accessToken });
|
||||
},
|
||||
async extract(path) {
|
||||
await superagent.put(`${origin}/api/v1/${api}/files/${path}`)
|
||||
.send({ action: 'extract' })
|
||||
.query({ access_token: accessToken });
|
||||
},
|
||||
async download(path) {
|
||||
window.open(`${origin}/api/v1/${api}/files/${path}?download=true&access_token=${accessToken}`);
|
||||
},
|
||||
async save(filePath, content) {
|
||||
const file = new File([content], 'file');
|
||||
await superagent.post(`${origin}/api/v1/${api}/files/${filePath}`)
|
||||
|
||||
@@ -62,6 +62,8 @@
|
||||
:copy-handler="copyHandler"
|
||||
:cut-handler="cutHandler"
|
||||
:paste-handler="pasteHandler"
|
||||
:download-handler="downloadHandler"
|
||||
:extract-handler="extractHandler"
|
||||
:new-file-handler="onNewFile"
|
||||
:new-folder-handler="onNewFolder"
|
||||
:upload-file-handler="onUploadFile"
|
||||
@@ -348,6 +350,12 @@ export default {
|
||||
this.clipboard = {};
|
||||
await this.loadCwd();
|
||||
},
|
||||
async downloadHandler(file) {
|
||||
await this.directoryModel.download(buildFilePath(this.cwd, file.name));
|
||||
},
|
||||
async extractHandler(file) {
|
||||
await this.directoryModel.extract(buildFilePath(this.cwd, file.name));
|
||||
},
|
||||
async uploadHandler(targetDir, file, progressHandler) {
|
||||
await this.directoryModel.upload(targetDir, file, progressHandler);
|
||||
await this.loadCwd();
|
||||
|
||||
Reference in New Issue
Block a user