Skip to content

Commit 3e8879f

Browse files
committed
Fix uploads not including filename
1 parent 652f655 commit 3e8879f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

mmpy_bot/driver.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,12 @@ def upload_files(
199199
) -> List[str]:
200200
"""Given a list of file paths and the channel id, uploads the corresponding
201201
files and returns a list their internal file IDs."""
202-
file_dict = {}
202+
file_list = []
203203
for path in file_paths:
204204
path = Path(path)
205-
file_dict[path.name] = Path(path).read_bytes()
205+
# Note: 'files' should be a name of an expected attribute in the body
206+
# but seems to be ignored when simply uploading files to mattermost
207+
file_list.append(("files", (path.name, Path(path).read_bytes(),)))
206208

207-
result = self.files.upload_file(channel_id, file_dict)
209+
result = self.files.upload_file(files=file_list, data={"channel_id": channel_id})
208210
return list(info["id"] for info in result["file_infos"])

0 commit comments

Comments
 (0)