@@ -170,83 +170,6 @@ def delete_project(self, project_id: str):
170170
171171 return resp
172172
173- def upload_files (
174- self ,
175- project_id : str ,
176- project_path : str ,
177- filter_glob : str = None ,
178- continue_on_error : bool = True ,
179- show_progress : bool = False ,
180- ) -> List [Dict ]:
181- """Upload files to a QFieldCloud project"""
182-
183- # skip temporary files (suffix ~)
184- # skip temporary files (.gpkg-sch and .gpkg-)
185-
186- if not filter_glob :
187- filter_glob = "*"
188-
189- files : List [Dict [str , Any ]] = []
190- for path in Path (project_path ).rglob (filter_glob ):
191- if not path .is_file ():
192- continue
193-
194- if str (path .relative_to (project_path )).startswith (".qfieldsync" ):
195- continue
196-
197- files .append (
198- {
199- "name" : str (path ),
200- "status" : UploadStatus .PENDING ,
201- "error" : None ,
202- }
203- )
204-
205- if not files :
206- return files
207-
208- # upload the QGIS project file at the end
209- files .sort (key = lambda f : Path (f ["name" ]).suffix .lower () in (".qgs" , ".qgz" ))
210-
211- for file in files :
212- local_path = Path (file ["name" ])
213-
214- remote_path = local_path .relative_to (project_path )
215-
216- with open (file ["name" ], "rb" ) as local_file :
217- upload_file = local_file
218- if show_progress :
219- from tqdm import tqdm
220- from tqdm .utils import CallbackIOWrapper
221-
222- progress_bar = tqdm (
223- total = local_path .stat ().st_size ,
224- unit_scale = True ,
225- desc = local_path .stem ,
226- )
227- upload_file = CallbackIOWrapper (
228- progress_bar .update , local_file , "read"
229- )
230-
231- try :
232- _ = self ._request (
233- "POST" ,
234- f"files/{ project_id } /{ remote_path } " ,
235- files = {
236- "file" : upload_file ,
237- },
238- )
239- file ["status" ] = UploadStatus .SUCCESS
240- except Exception as err :
241- file ["status" ] = UploadStatus .FAILED
242- file ["error" ] = err
243-
244- if continue_on_error :
245- continue
246- else :
247- raise err
248-
249- return files
250173
251174 def download_files (
252175 self ,
0 commit comments