notification manager
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
import os
|
||||
from os import remove
|
||||
|
||||
from aiohttp import web
|
||||
|
||||
|
||||
async def delete_file(request):
|
||||
if 'token' not in request.headers or request.headers['token'] != os.getenv('FS_TOKEN'):
|
||||
return web.json_response({"success": False}, status=403)
|
||||
remove("data/" + request.rel_url.query['id'])
|
||||
return web.json_response({"success": True})
|
||||
|
@@ -1,8 +1,12 @@
|
||||
import os
|
||||
|
||||
import aiofiles
|
||||
from aiohttp import web
|
||||
|
||||
|
||||
async def get_file(request):
|
||||
if 'token' not in request.headers or request.headers['token'] != os.getenv('FS_TOKEN'):
|
||||
return web.json_response({"success": False}, status=403)
|
||||
response = web.StreamResponse()
|
||||
await response.prepare(request)
|
||||
async with aiofiles.open("data/" + request.rel_url.query['id'], "rb") as fs:
|
||||
|
@@ -1,3 +1,5 @@
|
||||
import os
|
||||
|
||||
from aiohttp import web
|
||||
|
||||
from FileStorage.sync import write_meta
|
||||
@@ -5,6 +7,8 @@ import aiofiles
|
||||
|
||||
|
||||
async def upload_file(request):
|
||||
if 'token' not in request.headers or request.headers['token'] != os.getenv('FS_TOKEN'):
|
||||
return web.json_response({"success": False}, status=403)
|
||||
file_id = await write_meta(request)
|
||||
async with aiofiles.open("data/" + str(file_id), "wb") as fs:
|
||||
await fs.write(await request.content.read())
|
||||
|
Reference in New Issue
Block a user