Skip to content

Commit

Permalink
added file upload
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasunique committed Jul 7, 2024
1 parent 3f1f7fe commit ee8da42
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion unique_sdk/unique_sdk/api_resources/_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ class Input(TypedDict):

class UpsertParams(RequestOptions):
input: "Content.Input"
scopeId: str
scopeId: Optional[str]
chatId: Optional[str]
sourceOwnerType: str
storeInternally: bool
fileUrl: Optional[str]
Expand Down
5 changes: 4 additions & 1 deletion unique_sdk/unique_sdk/utils/file_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def upload_file(
path_to_file,
displayed_filename,
mime_type,
scope_or_unique_path,
scope_or_unique_path=None,
chat_id=None,
):
size = os.path.getsize(path_to_file)
createdContent = unique_sdk.Content.upsert(
Expand All @@ -48,6 +49,7 @@ def upload_file(
"mimeType": mime_type,
},
scopeId=scope_or_unique_path,
chatId=chat_id,
)

uploadUrl = createdContent.writeUrl
Expand All @@ -74,6 +76,7 @@ def upload_file(
},
scopeId=scope_or_unique_path,
fileUrl=createdContent.readUrl,
chatId=chat_id,
)

return createdContent
Expand Down

0 comments on commit ee8da42

Please sign in to comment.