@@ -35,7 +35,24 @@ def upload_file(
35
35
mime_type : str | None = None ,
36
36
name : str | None = None ,
37
37
display_name : str | None = None ,
38
+ resumable : bool = True ,
38
39
) -> file_types .File :
40
+ """Uploads a file using a supported file service.
41
+
42
+ Args:
43
+ path: The path to the file to be uploaded.
44
+ mime_type: The MIME type of the file. If not provided, it will be
45
+ inferred from the file extension.
46
+ name: The name of the file in the destination (e.g., 'files/sample-image').
47
+ If not provided, a system generated ID will be created.
48
+ display_name: Optional display name of the file.
49
+ resumable: Whether to use the resumable upload protocol. By default, this is enabled.
50
+ See details at
51
+ https://googleapis.github.io/google-api-python-client/docs/epy/googleapiclient.http.MediaFileUpload-class.html#resumable
52
+
53
+ Returns:
54
+ file_types.File: The response of the uploaded file.
55
+ """
39
56
client = get_default_file_client ()
40
57
41
58
path = pathlib .Path (os .fspath (path ))
@@ -50,7 +67,7 @@ def upload_file(
50
67
display_name = path .name
51
68
52
69
response = client .create_file (
53
- path = path , mime_type = mime_type , name = name , display_name = display_name
70
+ path = path , mime_type = mime_type , name = name , display_name = display_name , resumable = resumable
54
71
)
55
72
return file_types .File (response )
56
73
0 commit comments