Added better file handling.
This commit is contained in:
parent
c4e3f1fc1f
commit
c6c2766381
@ -25,6 +25,7 @@ class UploadView(BaseView):
|
||||
drive_item = await self.services.drive_item.get(uid)
|
||||
response = web.FileResponse(drive_item["path"])
|
||||
response.headers['Cache-Control'] = f'public, max-age={1337*420}'
|
||||
response.headers['Content-Disposition'] = f'attachment; filename="{drive_item["name"]}"'
|
||||
return response
|
||||
|
||||
async def post(self):
|
||||
@ -58,7 +59,9 @@ class UploadView(BaseView):
|
||||
if not filename:
|
||||
continue
|
||||
|
||||
file_path = pathlib.Path(UPLOAD_DIR).joinpath(filename.strip("/").strip("."))
|
||||
name = str(uuid.uuid4()) + pathlib.Path(filename).suffix
|
||||
|
||||
file_path = pathlib.Path(UPLOAD_DIR).joinpath(name)
|
||||
files.append(file_path)
|
||||
|
||||
async with aiofiles.open(str(file_path.absolute()), 'wb') as f:
|
||||
|
Loading…
Reference in New Issue
Block a user