Skip to content

Docs are incorrect regarding UploadFile #9922

Answered by mateoradman
holyoaks asked this question in Questions
Discussion options

You must be logged in to vote

Hi @holyoaks,

I believe what is stated in the docs is absolutely correct. That is, an instance of an UploadFile indeed has a content_type attribute. Having an attribute does not imply that UploadFile accepts content_type in the __init__ method.

Looking into the signature of the UploadFile class one can see that a content_type is a property method. This means that this attribute content_type is calculate on the fly every time you access some_file.content_type attribute.

class UploadFile:
    """
    An uploaded file included as part of the request data.
    """

    def __init__(
        self,
        file: typing.BinaryIO,
        *,
        size: typing.Optional[int] = None,
        file…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@holyoaks
Comment options

Answer selected by Kludex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question or problem
2 participants