Skip to content

Commit

Permalink
Add webp to mimetypes (#440)
Browse files Browse the repository at this point in the history
* Add webp to mimetypes

Change-Id: Ib68aecf16156b09e3261158dd5915a0c9bea642a

* format

Change-Id: I43edff4274d09ce636ceffdf39e4cbc0bbe1da49

* add-test

Change-Id: I829e3ce10e6f6a9d406ebf79662a4d8c83b48f9d
  • Loading branch information
MarkDaoust authored Jul 8, 2024
1 parent 13d2f52 commit d9a17ea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions google/generativeai/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

__all__ = ["upload_file", "get_file", "list_files", "delete_file"]

mimetypes.add_type("image/webp", ".webp")


def upload_file(
path: str | pathlib.Path | os.PathLike,
Expand Down
7 changes: 7 additions & 0 deletions tests/test_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,10 @@ def test_video_metadata(self):
def test_to_file_data(self, file_data):
file_data = file_types.to_file_data(file_data)
self.assertEqual(protos.FileData(file_uri="https://test_uri"), file_data)

def test_webp_mimetype(self):
self.responses["create_file"].append(protos.File())

response = genai.upload_file("test.webp")

self.assertEqual("image/webp", self.observed_requests[0]["mime_type"])

0 comments on commit d9a17ea

Please sign in to comment.