Move file upload logic to data model
This commit is contained in:
@@ -26,6 +26,12 @@ export function createDirectoryModel(origin, accessToken, api) {
|
||||
|
||||
return result.body.entries;
|
||||
},
|
||||
async upload(targetDir, file, progressHandler) {
|
||||
await superagent.post(`${origin}/api/v1/${api}/files/${encodeURIComponent(sanitize(targetDir + '/' + file.name))}`)
|
||||
.query({ access_token: accessToken })
|
||||
.attach('file', file)
|
||||
.on('progress', progressHandler);
|
||||
},
|
||||
async remove(filePath) {
|
||||
const [error] = await safe(superagent.del(`${origin}/api/v1/${api}/files/${filePath}`)
|
||||
.query({ access_token: accessToken }));
|
||||
|
||||
Reference in New Issue
Block a user