Skip to content
This repository has been archived by the owner on Apr 30, 2020. It is now read-only.

Commit

Permalink
issue #77 Encode download API url
Browse files Browse the repository at this point in the history
disabling `/file/` API
  • Loading branch information
lunik committed Nov 5, 2017
1 parent 1d1f986 commit 704bcb9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/public/components/toolbox/item/file/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class CopyToolboxItem extends React.Component {
}

handleClick () {
copy(window.location.origin + this.props.file.copy)
copy(window.location.origin + this.props.file.download)
}

render () {
Expand Down
4 changes: 1 addition & 3 deletions src/server/model/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ export default class File extends EventEmitter {
toJSON () {
let cleanBase = this.base.split('/').slice(2).join('/')
let url = Path.join('/folder', cleanBase, this.name)
let download = Path.join('/file', cleanBase, this.name)
let copy = '/dl/' + Crypto.Rabbit.encrypt(Path.join(cleanBase, this.name), config.server.masterKey).toString()
let download = '/dl/' + Crypto.Rabbit.encrypt(Path.join(cleanBase, this.name), config.server.masterKey).toString()
let path = Path.join(cleanBase, this.name)
return {
name: this.name,
Expand All @@ -133,7 +132,6 @@ export default class File extends EventEmitter {
childs: this.childs,
url,
download: this instanceof Folder ? null : download,
copy: this instanceof Folder ? null : copy,
path: this instanceof Folder ? path : null
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/server/routes/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ const config = new Config({sync: true})
var log = new Delogger('File')

module.exports = (app, baseFolder) => {
app.get('/file/:path((*)/?*)', (req, res) => {
/* app.get('/file/:path((*)/?*)', (req, res) => {
var path = req.params.path
Download(req, res, path)
})
}) */

app.get('/dl/:file(*)', (req, res) => {
var path = Crypto.Rabbit.decrypt(req.params.file, config.server.masterKey).toString(Crypto.enc.Utf8)
Expand Down

0 comments on commit 704bcb9

Please sign in to comment.