@request_handler
    @defer.inlineCallbacks
    def _async_render_POST(self, request):
        requester = yield self.auth.get_user_by_req(request)
        # TODO: The checks here are a bit late. The content will have
        # already been uploaded to a tmp file at this point
        content_length = request.getHeader("Content-Length")
        if content_length is None:
            raise SynapseError(
                msg="Request must specify a Content-Length", code=400
            )
        if int(content_length) > self.max_upload_size:
            raise SynapseError(
                msg="Upload request body is too large",
                code=413,
            )

        upload_name = request.args.get("filename", None)
        if upload_name:
            try:
                upload_name = upload_name[0].decode('UTF-8')
            except __HOLE__:
                raise SynapseError(
                    msg="Invalid UTF-8 filename parameter: %r" % (upload_name),
                    code=400,
                )

        headers = request.requestHeaders

        if headers.hasHeader("Content-Type"):
            media_type = headers.getRawHeaders("Content-Type")[0]
        else:
            raise SynapseError(
                msg="Upload request missing 'Content-Type'",
                code=400,
            )

        # if headers.hasHeader("Content-Disposition"):
        #     disposition = headers.getRawHeaders("Content-Disposition")[0]
        # TODO(markjh): parse content-dispostion

        content_uri = yield self.create_content(
            media_type, upload_name, request.content.read(),
            content_length, requester.user
        )

        respond_with_json(
            request, 200, {"content_uri": content_uri}, send_cors=True
        )
dataset/ETHPy150Open matrix-org/synapse/synapse/rest/media/v1/upload_resource.py/UploadResource._async_render_POST