fix: Adjust multipart form to use raw UTF-8 encoding for filenames in file uploads
This commit is contained in:
@@ -69,8 +69,16 @@ class XAIService:
|
||||
url = f"{XAI_FILES_URL}/v1/files"
|
||||
headers = {"Authorization": f"Bearer {self.api_key}"}
|
||||
|
||||
form = aiohttp.FormData()
|
||||
form.add_field('file', file_content, filename=filename, content_type=mime_type)
|
||||
# Create multipart form with explicit UTF-8 filename encoding
|
||||
# aiohttp automatically URL-encodes filenames with special chars,
|
||||
# but xAI expects raw UTF-8 in the filename parameter
|
||||
form = aiohttp.FormData(quote_fields=False)
|
||||
form.add_field(
|
||||
'file',
|
||||
file_content,
|
||||
filename=filename,
|
||||
content_type=mime_type
|
||||
)
|
||||
|
||||
async with session.post(url, data=form, headers=headers) as response:
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user