jeremyephron / simplegmail

A simple Gmail API client for applications in Python
MIT License
336 stars 73 forks source link

Would like to have an API to get the size of attachments #84

Closed kodarahul closed 1 year ago

kodarahul commented 1 year ago
def size(self) -> None:
    """
    Get the size of data for an attachment if it does not exist.

    Raises:
        googleapiclient.errors.HttpError: There was an error executing the
            HTTP request.

    """

    if self.data is not None:
        return

    res = self._service.users().messages().attachments().get(
        userId=self.user_id, messageId=self.msg_id, id=self.id, fields='size'
    ).execute()

    return res['size']