adonis-dropbox
Advanced tools
Comparing version 0.2.0 to 0.3.0
{ | ||
"name": "adonis-dropbox", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -18,12 +18,20 @@ /** | ||
getRootPath() { | ||
const rootPath = this.Config.get('dropbox.rootPath') || '/'; | ||
return rootPath[rootPath.length - 1] === '/' ? rootPath : `${rootPath}/`; | ||
} | ||
async upload(buffer) { | ||
const rootPath = this.Config.get('dropbox.rootPath') || '/'; | ||
const { ext } = this.fileType(buffer); | ||
return this.client.filesUpload({ | ||
path: `${rootPath[rootPath.length - 1] === '/' ? rootPath : `${rootPath}/`}${new Date().getTime()}.${ext}`, | ||
path: `${this.getRootPath()}${new Date().getTime()}.${ext}`, | ||
contents: buffer, | ||
}); | ||
} | ||
async download(name, customPath = null) { | ||
return this.client.filesDownload({ path: `${customPath || this.getRootPath()}${name}` }); | ||
} | ||
} | ||
module.exports = AdonisDropbox; |
4815
71