-
Notifications
You must be signed in to change notification settings - Fork 709
Description
Environment details
- Programming language: Python
- OS: Window 11
- Language runtime version: 3.12.3
- Package version: 1.56.0
Thanks you for making this library to use Gemini API easily.
I'm currently working with File search stores method that you lunched in Nov. 2025. (quite recent)
And I have encounter trouble to upload files using Client.file_search_stores.upload_to_file_search_store method with config argument.
Specifically, I upload .sh file with configuration of mime_type which is contained parameter in UploadToFileSearchStoreConfig as followed.
from google import genai
client = genai.Client()
operation = client.file_search_stores.upload_to_file_search_store(
file="Data/code/dummy_script.sh",
file_search_store_name=my_file_store_name,
config = {
"display_name": "test_mime",
"mime_type": 'application/x-sh'
}
)Then, I got 400 invalid error :
400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': "* UploadToFileSearchStoreRequest.mime_type: When provided, MIME type must be in a valid type/subtype format (e.g., 'text/plain', 'application/pdf').\n", 'status': 'INVALID_ARGUMENT'}}
However, If I do not contain "mime_type" in config params, It works well. For example,
operation = client.file_search_stores.upload_to_file_search_store(
file="Data/code/dummy_script.sh",
file_search_store_name=my_file_store_name,
config = {
"display_name": "test_mime",
# "mime_type": 'application/x-sh'
}
)Above code work well..
I suspect that the request parameter is not constructed well, and I check the HttpRequest used in _api_client._request() but I think this is not the problem.
HttpRequest(headers={'Content-Type': 'application/json', 'x-goog-api-key': '(my api key)', 'user-agent': 'google-genai-sdk/1.56.0 gl-python/3.12.3', 'x-goog-api-client': 'google-genai-sdk/1.56.0 gl-python/3.12.3', 'X-Goog-Upload-Protocol': 'resumable', 'X-Goog-Upload-Command': 'start', 'X-Goog-Upload-Header-Content-Length': '900', 'X-Goog-Upload-Header-Content-Type': 'application/x-sh', 'X-Goog-Upload-File-Name': 'dummy_script.sh'}, url='https://generativelanguage.googleapis.com/upload/v1beta/(my file store name)', method='post', data={'mimeType': 'application/x-sh', 'displayName': 'test_mime'}, timeout=None)
Thanks you for reading and I wish this could be helpful for other users.