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"
|
return url_for("get", path=n, _external=True) + "\n"
|
||||||
|
|
||||||
def store(file_, addr):
|
def store(file_, addr):
|
||||||
data = file_.stream.read()
|
data = file_.read()
|
||||||
digest = sha256(data).hexdigest()
|
digest = sha256(data).hexdigest()
|
||||||
|
|
||||||
def get_mime():
|
def get_mime():
|
||||||
|
@ -192,8 +192,8 @@ class File(db.Model):
|
||||||
p = storage / digest
|
p = storage / digest
|
||||||
|
|
||||||
if not p.is_file():
|
if not p.is_file():
|
||||||
file_.stream.seek(0)
|
with open(p, "wb") as of:
|
||||||
file_.save(p)
|
of.write(data)
|
||||||
else:
|
else:
|
||||||
p.touch()
|
p.touch()
|
||||||
|
|
||||||
|
@ -287,7 +287,7 @@ def store_url(url, addr):
|
||||||
def urlfile(**kwargs):
|
def urlfile(**kwargs):
|
||||||
return type('',(),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)
|
return store_file(f, addr)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue