mirror of
https://git.0x0.st/mia/0x0.git
synced 2024-11-22 00:47:12 +01:00
parent
5216e9ebaf
commit
c7a728ce84
1 changed files with 4 additions and 4 deletions
8
fhost.py
8
fhost.py
|
@ -140,7 +140,7 @@ class File(db.Model):
|
|||
return url_for("get", path=n, _external=True) + "\n"
|
||||
|
||||
def store(file_, addr):
|
||||
data = file_.stream.read()
|
||||
data = file_.read()
|
||||
digest = sha256(data).hexdigest()
|
||||
|
||||
def get_mime():
|
||||
|
@ -192,8 +192,8 @@ class File(db.Model):
|
|||
p = storage / digest
|
||||
|
||||
if not p.is_file():
|
||||
file_.stream.seek(0)
|
||||
file_.save(p)
|
||||
with open(p, "wb") as of:
|
||||
of.write(data)
|
||||
else:
|
||||
p.touch()
|
||||
|
||||
|
@ -287,7 +287,7 @@ def store_url(url, addr):
|
|||
def urlfile(**kwargs):
|
||||
return type('',(),kwargs)()
|
||||
|
||||
f = urlfile(stream=r.raw, content_type=r.headers["content-type"], filename="")
|
||||
f = urlfile(read=r.raw.read, content_type=r.headers["content-type"], filename="")
|
||||
|
||||
return store_file(f, addr)
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue