diff options
author | Patrick Cloke <clokep@users.noreply.github.com> | 2021-06-08 08:30:48 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-08 08:30:48 -0400 |
commit | 9e4610cc272fc8e5db39608de83ce48360889e42 (patch) | |
tree | 33158a167c6f8f4b558b110c669bec7670295557 /synapse/rest/media | |
parent | Name release branches just after major.minor (#10013) (diff) | |
download | synapse-9e4610cc272fc8e5db39608de83ce48360889e42.tar.xz |
Correct type hints for parse_string(s)_from_args. (#10137)
Diffstat (limited to 'synapse/rest/media')
-rw-r--r-- | synapse/rest/media/v1/upload_resource.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/synapse/rest/media/v1/upload_resource.py b/synapse/rest/media/v1/upload_resource.py index 024a105bf2..62dc4aae2d 100644 --- a/synapse/rest/media/v1/upload_resource.py +++ b/synapse/rest/media/v1/upload_resource.py @@ -14,13 +14,13 @@ # limitations under the License. import logging -from typing import IO, TYPE_CHECKING +from typing import IO, TYPE_CHECKING, Dict, List, Optional from twisted.web.server import Request from synapse.api.errors import Codes, SynapseError from synapse.http.server import DirectServeJsonResource, respond_with_json -from synapse.http.servlet import parse_string +from synapse.http.servlet import parse_bytes_from_args from synapse.http.site import SynapseRequest from synapse.rest.media.v1.media_storage import SpamMediaException @@ -61,10 +61,11 @@ class UploadResource(DirectServeJsonResource): errcode=Codes.TOO_LARGE, ) - upload_name = parse_string(request, b"filename", encoding=None) - if upload_name: + args = request.args # type: Dict[bytes, List[bytes]] # type: ignore + upload_name_bytes = parse_bytes_from_args(args, "filename") + if upload_name_bytes: try: - upload_name = upload_name.decode("utf8") + upload_name = upload_name_bytes.decode("utf8") # type: Optional[str] except UnicodeDecodeError: raise SynapseError( msg="Invalid UTF-8 filename parameter: %r" % (upload_name), code=400 |