new route to list files in a share. TODO: use for split upload to check existing splits
This commit is contained in:
40
README.md
40
README.md
@@ -75,3 +75,43 @@ Operation is one of download, direct_download, zip_download, or upload
|
||||
direct links. You can have many tokens for single share.
|
||||
- Direct download token is (password hash + filename) hashed
|
||||
|
||||
|
||||
# Routes
|
||||
|
||||
- @app.route("/")
|
||||
Display the list of public shares, or the ones logged in to
|
||||
- @app.route('/authenticate/<name>', methods=['GET','POST'])
|
||||
Query the password for the share
|
||||
- @app.route('/upload/<name>/<token>', methods=['POST'])
|
||||
Upload a file from command line
|
||||
- @app.route('/upload', methods=['POST'])
|
||||
Upload file from the browser
|
||||
- @app.route('/upload_join/<name>/<token>', methods=['POST'])
|
||||
Commence joining of a splitted upload file
|
||||
- @app.route('/files/<name>/<token>', methods=['GET'])
|
||||
Return plain text list of files in the share
|
||||
- @app.route('/list/<name>/<token>', methods=['GET'])
|
||||
Login to a share with a token
|
||||
- @app.route('/list/<name>', methods=['GET'])
|
||||
List share contents for the browser
|
||||
- @app.route('/logout/<name>', methods=['GET'])
|
||||
Logout from share. Only for browser.
|
||||
- @app.route('/direct/<name>/<token>/<filename>', methods=['GET'])
|
||||
Download a file using the filename token (if direct download enabled)
|
||||
- @app.route('/download/<name>/<token>/<filename>', methods=['GET'])
|
||||
Download a file using the share token
|
||||
- @app.route('/download/<name>/<filename>', methods=['GET'])
|
||||
Download a file with a browser
|
||||
- @app.route('/zip/<name>/<token>', methods=['GET'])
|
||||
Download the whole share as a zip file using share token
|
||||
- @app.route('/zip/<name>', methods=['GET'])
|
||||
Download the whole share as a zip file using browser
|
||||
- @app.route('/script/upload/<name>/<token>', methods=['GET'])
|
||||
Get a bash script that uploads multiple files. Folders are uploaded as .tar.gz
|
||||
- @app.route('/script/download/<name>/<token>', methods=['GET'])
|
||||
Get a bash script that downloads all the files in a share.
|
||||
- @app.route('/script/direct/<name>/<token>', methods=['GET'])
|
||||
Get a bash script that downloads all the files in a share using direct filename tokens.
|
||||
- @app.route('/script/upload_split/<name>/<token>', methods=['GET'])
|
||||
Get a bash script that uploads multiple files and folders. The script splits files
|
||||
to smaller chunks, to prevent timeouts. Folders are uploaded as .tar
|
||||
|
||||
17
code/app.py
17
code/app.py
@@ -8,6 +8,7 @@ from flask import Flask, render_template, jsonify, current_app, Response, \
|
||||
redirect, url_for, request, g, session, send_file, send_from_directory
|
||||
from werkzeug.utils import secure_filename
|
||||
import zipfile
|
||||
import urllib
|
||||
from multiprocessing import Process
|
||||
from revprox import ReverseProxied
|
||||
from utils.utils import *
|
||||
@@ -169,6 +170,22 @@ def send(name):
|
||||
return share
|
||||
return render_template('send.html',name=name)
|
||||
|
||||
@app.route('/files/<name>/<token>', methods=['GET'])
|
||||
def list_files(name, token):
|
||||
(ok,share) = get_share(name, token = token)
|
||||
if not ok:
|
||||
return share
|
||||
files = []
|
||||
for file in sorted(os.listdir(share['path'])):
|
||||
fp = os.path.join(share['path'],file)
|
||||
if os.path.isdir(fp):
|
||||
continue
|
||||
if file.startswith("."):
|
||||
continue
|
||||
files.append(urllib.parse.quote_plus(file))
|
||||
files.append("")
|
||||
return "\n".join(files), 200
|
||||
|
||||
@app.route('/list/<name>/<token>', methods=['GET'])
|
||||
@app.route('/list/<name>', methods=['GET'])
|
||||
def list_view(name, token = None):
|
||||
|
||||
Reference in New Issue
Block a user