Skip to content

Commit

Permalink
Merge branch 'master' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
r0nni3 committed May 14, 2024
2 parents 1c198e7 + 6311ea1 commit 73961c6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/alfred/rest/files/v1.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Native imports
import os
import json
from typing import Text
from io import BufferedReader
from urllib.parse import unquote
Expand Down Expand Up @@ -48,13 +49,17 @@ def upload_file(self, payload: UploadLocalFilePayload) -> UploadResponse:
if not filename:
raise AlfredMissingArgument("filename must be provided.")

files = [("file", (filename, file, "application/octet-stream"))]

data = {key: value for key, value in payload.items() if key != "file"}
files = [
("file", (filename, file, "application/octet-stream")),
("session_id", (None, payload["session_id"], "text/plain")),
(
"metadata",
(None, json.dumps(payload.get("metadata")), "application/json"),
),
]

parsed_resp, _ = self.http_client.post(
"/api/file/uploadfile",
data=data,
files=files,
headers={"content-type": None},
)
Expand Down

0 comments on commit 73961c6

Please sign in to comment.