mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 00:52:16 -06:00
og: support filekeys
This commit is contained in:
parent
e45420646f
commit
ae98200660
|
@ -1159,8 +1159,6 @@ note that this disables hotlinking because the opengraph spec demands it; to sne
|
|||
|
||||
you can also hotlink files regardless by appending `?raw` to the url
|
||||
|
||||
NOTE: because discord (and maybe others) strip query args such as `?raw` in opengraph tags, any links which require a filekey or dirkey will not work
|
||||
|
||||
if you want to entirely replace the copyparty response with your own jinja2 template, give the template filepath to `--og-tpl` or volflag `og_tpl` (all members of `HttpCli` are available through the `this` object)
|
||||
|
||||
|
||||
|
@ -2087,6 +2085,8 @@ volflag `dky` disables the actual key-check, meaning anyone can see the contents
|
|||
|
||||
volflag `dks` lets people enter subfolders as well, and also enables download-as-zip/tar
|
||||
|
||||
if you enable dirkeys, it is probably a good idea to enable filekeys too, otherwise it will be impossible to hotlink files from a folder which was accessed using a dirkey
|
||||
|
||||
dirkeys are generated based on another salt (`--dk-salt`) + filesystem-path and have a few limitations:
|
||||
* the key does not change if the contents of the folder is modified
|
||||
* if you need a new dirkey, either change the salt or rename the folder
|
||||
|
|
|
@ -5535,6 +5535,8 @@ class HttpCli(object):
|
|||
fmt = vn.flags.get("og_th", "j")
|
||||
th_base = ujoin(url_base, quotep(thumb))
|
||||
query = "th=%s&cache" % (fmt,)
|
||||
if use_filekey:
|
||||
query += "&k=" + self.uparam["k"]
|
||||
query = ub64enc(query.encode("utf-8")).decode("ascii")
|
||||
# discord looks at file extension, not content-type...
|
||||
query += "/th.jpg" if "j" in fmt else "/th.webp"
|
||||
|
@ -5544,7 +5546,10 @@ class HttpCli(object):
|
|||
j2a["og_file"] = file
|
||||
if og_fn:
|
||||
og_fn_q = quotep(og_fn)
|
||||
query = ub64enc(b"raw").decode("ascii")
|
||||
query = "raw"
|
||||
if use_filekey:
|
||||
query += "&k=" + self.uparam["k"]
|
||||
query = ub64enc(query.encode("utf-8")).decode("ascii")
|
||||
query += "/%s" % (og_fn_q,)
|
||||
j2a["og_url"] = ujoin(url_base, og_fn_q)
|
||||
j2a["og_raw"] = j2a["og_url"] + "/.uqe/" + query
|
||||
|
|
Loading…
Reference in a new issue