@@ -88,8 +88,10 @@ def upload_file(
88
88
)
89
89
return file_types .File (response )
90
90
91
+
91
92
async def upload_file_async (* args , ** kwargs ):
92
- return await asyncio .to_thread (upload_file , * args , ** kwargs )
93
+ return await asyncio .to_thread (upload_file , * args , ** kwargs )
94
+
93
95
94
96
def list_files (page_size = 100 ) -> Iterable [file_types .File ]:
95
97
"""Calls the API to list files using a supported file service."""
@@ -99,19 +101,23 @@ def list_files(page_size=100) -> Iterable[file_types.File]:
99
101
for proto in response :
100
102
yield file_types .File (proto )
101
103
104
+
102
105
async def list_files_async (* args , ** kwargs ):
103
106
return await asyncio .to_thread (list_files , * args , ** kwargs )
104
107
108
+
105
109
def get_file (name : str ) -> file_types .File :
106
110
"""Calls the API to retrieve a specified file using a supported file service."""
107
111
if "/" not in name :
108
112
name = f"files/{ name } "
109
113
client = get_default_file_client ()
110
114
return file_types .File (client .get_file (name = name ))
111
115
116
+
112
117
async def get_file_async (* args , ** kwargs ):
113
118
return await asyncio .to_thread (get_file , * args , ** kwargs )
114
119
120
+
115
121
def delete_file (name : str | file_types .File | protos .File ):
116
122
"""Calls the API to permanently delete a specified file using a supported file service."""
117
123
if isinstance (name , (file_types .File , protos .File )):
@@ -122,5 +128,6 @@ def delete_file(name: str | file_types.File | protos.File):
122
128
client = get_default_file_client ()
123
129
client .delete_file (request = request )
124
130
131
+
125
132
async def delete_file_async (* args , ** kwargs ):
126
- return await asyncio .to_thread (get_file , * args , ** kwargs )
133
+ return await asyncio .to_thread (get_file , * args , ** kwargs )
0 commit comments