Ejemplo n.º 1
0
async def view_upload(request):
    """Load multipart data and store it as a file."""
    formdata = await request.form()
    if formdata is None or 'file' not in formdata:
        return bad_request()

    with open(f"/tmp/{uuid4().hex}", 'w') as target:
        target.write(formdata['file'])

    return text(target.name)
Ejemplo n.º 2
0
 def bad_request(self, message: MessageType = None) -> Response:
     """
     Returns an HTTP 400 Bad Request response, with optional message;
     sent as plain text or JSON.
     """
     return bad_request(message)