File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
src/segmentation_skeleton_metrics/utils Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -247,6 +247,22 @@ def list_gcs_subdirectories(bucket_name, prefix):
247247 return subdirs
248248
249249
250+ def upload_directory_to_gcs (bucket_name , source_dir , destination_dir ):
251+ client = storage .Client ()
252+ bucket = client .bucket (bucket_name )
253+ for root , _ , files in os .walk (source_dir ):
254+ for filename in files :
255+ local_path = os .path .join (root , filename )
256+
257+ # Compute the relative path and GCS destination path
258+ relative_path = os .path .relpath (local_path , start = source_dir )
259+ blob_path = os .path .join (destination_dir , relative_path ).replace ("\\ " , "/" )
260+
261+ # Upload the file
262+ blob = bucket .blob (blob_path )
263+ blob .upload_from_filename (local_path )
264+
265+
250266# --- Miscellaneous ---
251267def get_segment_id (filename ):
252268 """
You can’t perform that action at this time.
0 commit comments