Commit f66b47bd by Johannes Zellner

Add file download button

1 parent 789485e5
......@@ -183,6 +183,7 @@
<th><span v-my-tooltip="foobar" data-toggle="tooltip" title="{{ entry.mtime }}">{{ entry.mtime | prettyDate }}</span></th>
<th style="text-align: right;">
<span class="entry-toolbar">
<button class="btn btn-sm btn-default" v-on:click.stop="download(entry)" title="Download" v-show="entry.isFile"><i class="fa fa-download"></i></button>
<button class="btn btn-sm btn-default" v-on:click.stop="renameAsk(entry)" title="Rename"><i class="fa fa-pencil"></i></button>
<button class="btn btn-sm btn-danger" v-on:click.stop="delAsk(entry)" title="Delete"><i class="fa fa-trash"></i></button>
</span>
......
......@@ -135,6 +135,12 @@ function open(entry) {
window.open(encode(path));
}
function download(entry) {
if (entry.isDirectory) return;
window.open(encode('/api/files/' + sanitize(app.path + '/' + entry.filePath)) + '?access_token=' + localStorage.accessToken);
}
function up() {
window.location.hash = sanitize(app.path.split('/').slice(0, -1).filter(function (p) { return !!p; }).join('/'));
}
......@@ -329,6 +335,7 @@ var app = new Vue({
logout: logout,
loadDirectory: loadDirectory,
open: open,
download: download,
up: up,
upload: upload,
delAsk: delAsk,
......
......@@ -88,7 +88,7 @@ function get(req, res, next) {
debug('get', absoluteFilePath);
if (!result.isDirectory() && !result.isFile()) return next(new HttpError(500, 'unsupported type'));
if (result.isFile()) return res.sendFile(absoluteFilePath);
if (result.isFile()) return res.download(absoluteFilePath);
async.map(fs.readdirSync(absoluteFilePath), function (filePath, callback) {
fs.stat(path.join(absoluteFilePath, filePath), function (error, result) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!