Skip to content

Commit 65c2073

Browse files
committed
Fix uploads not including filename
1 parent c3e892a commit 65c2073

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

mmpy_bot/driver.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,22 @@ 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(
208+
(
209+
"files",
210+
(
211+
path.name,
212+
Path(path).read_bytes(),
213+
),
214+
)
215+
)
206216

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

0 commit comments

Comments
 (0)