I have a function/method that creates a new attachment, particularly a text file, to a card. It successfully attaches the file to the card but when downloaded locally, the filename is always set to "Upload", not the actual filename "*.txt". Here's my function:
def create_attachment_on_card(self, card_id, filename):
"""
creates a file attachment on a card
"""
url = f"https://api.trello.com/1/cards/{card_id}/attachments"
with open(f'dataset/{filename}.txt', 'rb') as file:
content = file.read()
query = {
'key': self.key,
'token': self.token,
'name': f'{filename}.txt',
'file': content,
'mimeType': 'text/plain'
}
response = requests.request(
"POST",
url,
headers=self.std_headers,
params=query
)
return response.status_code
I would greatly appreciate any input on this. Thank you!