Patch up deletion
This commit is contained in:
@@ -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}`));
|
||||
|
||||
Reference in New Issue
Block a user