style: remove extension from stored files' names
This commit is contained in:
parent
ff13997bbd
commit
844ad5452e
@ -276,7 +276,7 @@ class TSession:
|
|||||||
res = cur.fetchone()
|
res = cur.fetchone()
|
||||||
file_id = res["f_id"]
|
file_id = res["f_id"]
|
||||||
ext = res["ext"]
|
ext = res["ext"]
|
||||||
file_path = join(conf["Paths"]["Files"], "%s.%s" % (file_id, ext))
|
file_path = join(conf["Paths"]["Files"], file_id)
|
||||||
move(path, file_path)
|
move(path, file_path)
|
||||||
thumb_path = previewer.get_jpeg_preview(file_path, height=160, width=160)
|
thumb_path = previewer.get_jpeg_preview(file_path, height=160, width=160)
|
||||||
preview_path = previewer.get_jpeg_preview(file_path, height=1080, width=1920)
|
preview_path = previewer.get_jpeg_preview(file_path, height=1080, width=1920)
|
||||||
|
|||||||
@ -17,7 +17,7 @@ function files_load() {
|
|||||||
success: function (resp) {
|
success: function (resp) {
|
||||||
$("#loader").css("display", "none");
|
$("#loader").css("display", "none");
|
||||||
resp.forEach((file) => {
|
resp.forEach((file) => {
|
||||||
container.append(`<div class="item-preview file-preview" file_id="${file.id}"><img src="/static/thumbs/${file.id}.${file.extension}" alt="" class="file-thumb"><div class="overlay"></div></div>`);
|
container.append(`<div class="item-preview file-preview" file_id="${file.id}"><img src="/static/thumbs/${file.id}" alt="" class="file-thumb"><div class="overlay"></div></div>`);
|
||||||
});
|
});
|
||||||
if (resp.length == 50) {
|
if (resp.length == 50) {
|
||||||
load_lock = false;
|
load_lock = false;
|
||||||
|
|||||||
@ -7,8 +7,8 @@
|
|||||||
</head>
|
</head>
|
||||||
<body data-bs-theme="dark">
|
<body data-bs-theme="dark">
|
||||||
<div class="file">
|
<div class="file">
|
||||||
<a href="/static/files/{{ file['id'] }}.{{ file['extension'] }}" class="preview-link" target="_blank">
|
<a href="/static/files/{{ file['id'] }}" class="preview-link" target="_blank">
|
||||||
<img src="/static/previews/{{ file['id'] }}.{{ file['extension'] }}" alt="{{ file['id'] }}.{{ file['extension'] }}" class="preview-img">
|
<img src="/static/previews/{{ file['id'] }}" alt="{{ file['id'] }}" class="preview-img">
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<header>
|
<header>
|
||||||
|
|||||||
@ -401,47 +401,60 @@ def files_delete():
|
|||||||
return jsonify({"status": False, "error": str(e).split('\n')[0]})
|
return jsonify({"status": False, "error": str(e).split('\n')[0]})
|
||||||
|
|
||||||
|
|
||||||
@app.route("/static/files/<file_id>.<ext>", methods=["GET"])
|
@app.route("/static/files/<file_id>", methods=["GET"])
|
||||||
def file_full(file_id=None, ext=None):
|
def file_full(file_id=None):
|
||||||
try:
|
try:
|
||||||
ts = tfm_api.TSession(session.get("id"))
|
ts = tfm_api.TSession(session.get("id"))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logout()
|
logout()
|
||||||
abort(404)
|
abort(404)
|
||||||
try:
|
try:
|
||||||
if not ts.get_file(file_id):
|
file = ts.get_file(file_id)
|
||||||
|
if not file:
|
||||||
raise RuntimeError("File does not exist")
|
raise RuntimeError("File does not exist")
|
||||||
return send_file(join(tfm_api.conf["Paths"]["Files"], "%s.%s" % (file_id, ext)))
|
return send_file(
|
||||||
|
join(tfm_api.conf["Paths"]["Files"], file_id),
|
||||||
|
mimetype=file["mime_name"],
|
||||||
|
download_name=(file["orig_name"] if file["orig_name"] else "%s.%s" % (file_id, file["extension"]))
|
||||||
|
)
|
||||||
except:
|
except:
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/static/thumbs/<file_id>.<ext>", methods=["GET"])
|
@app.route("/static/thumbs/<file_id>", methods=["GET"])
|
||||||
def thumb(file_id=None, ext=None):
|
def thumb(file_id=None):
|
||||||
try:
|
try:
|
||||||
ts = tfm_api.TSession(session.get("id"))
|
ts = tfm_api.TSession(session.get("id"))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logout()
|
logout()
|
||||||
abort(404)
|
abort(404)
|
||||||
try:
|
try:
|
||||||
if not ts.get_file(file_id):
|
file = ts.get_file(file_id)
|
||||||
|
if not file:
|
||||||
raise RuntimeError("File does not exist")
|
raise RuntimeError("File does not exist")
|
||||||
return send_file(tfm_api.previewer.get_jpeg_preview(join(tfm_api.conf["Paths"]["Files"], "%s.%s" % (file_id, ext)), height=160, width=160))
|
return send_file(
|
||||||
|
tfm_api.previewer.get_jpeg_preview(join(tfm_api.conf["Paths"]["Files"], file_id), height=160, width=160),
|
||||||
|
mimetype=file["mime_name"]
|
||||||
|
)
|
||||||
except:
|
except:
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/static/previews/<file_id>.<ext>", methods=["GET"])
|
@app.route("/static/previews/<file_id>", methods=["GET"])
|
||||||
def preview(file_id=None, ext=None):
|
def preview(file_id=None):
|
||||||
try:
|
try:
|
||||||
ts = tfm_api.TSession(session.get("id"))
|
ts = tfm_api.TSession(session.get("id"))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logout()
|
logout()
|
||||||
abort(404)
|
abort(404)
|
||||||
try:
|
try:
|
||||||
if not ts.get_file(file_id):
|
file = ts.get_file(file_id)
|
||||||
|
if not file:
|
||||||
raise RuntimeError("File does not exist")
|
raise RuntimeError("File does not exist")
|
||||||
return send_file(tfm_api.previewer.get_jpeg_preview(join(tfm_api.conf["Paths"]["Files"], "%s.%s" % (file_id, ext)), height=1080, width=1920))
|
return send_file(
|
||||||
|
tfm_api.previewer.get_jpeg_preview(join(tfm_api.conf["Paths"]["Files"], file_id), height=1080, width=1920),
|
||||||
|
mimetype=file["mime_name"]
|
||||||
|
)
|
||||||
except:
|
except:
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user