Patch up deletion

This commit is contained in:
Johannes Zellner
2023-04-02 10:06:14 +02:00
parent c79fc1abdd
commit e2de107067
2 changed files with 18 additions and 7 deletions
+11 -2
View File
@@ -1,6 +1,7 @@
import superagent from 'superagent';
import safe from 'safetydance';
import { sanitize } from 'pankow/utils';
export function createDirectoryModel(origin, accessToken, appId) {
return {
@@ -21,8 +22,16 @@ export function createDirectoryModel(origin, accessToken, appId) {
return result.body.entries;
},
async rename(oldPath, newPath) {
async remove(filePath) {
const [error] = await safe(superagent.del(`${origin}/api/v1/apps/${appId}/files/${filePath}`)
.query({ access_token: accessToken }));
if (error) throw error;
},
async rename(fromFilePath, toFilePath) {
const [error] = await safe(superagent.put(`${origin}/api/v1/apps/${appId}/files/${fromFilePath}`)
.send({ action: 'rename', newFilePath: sanitize(toFilePath) })
.query({ access_token: accessToken }));
if (error) throw error;
},
async getFile(path) {
const [error, result] = await safe(fetch(`${origin}/api/v1/apps/${appId}/files/${path}?access_token=${accessToken}`));