We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 76da170 commit a691860Copy full SHA for a691860
1 file changed
src/openpois/io/s3.py
@@ -43,3 +43,25 @@ def upload_partitioned_dataset(
43
)
44
45
return len(parquet_files)
46
+
47
48
+def upload_single_file(
49
+ local_path: Path,
50
+ bucket: str,
51
+ s3_key: str,
52
+ s3_region: str,
53
+ content_type: str = "application/octet-stream",
54
+) -> str:
55
+ """Upload a single local file to S3.
56
57
+ Returns the public HTTPS URL of the uploaded object.
58
+ """
59
+ s3 = boto3.client("s3", region_name = s3_region)
60
+ print(f"Uploading {local_path.name} to s3://{bucket}/{s3_key} ...")
61
+ s3.upload_file(
62
+ Filename = str(local_path),
63
+ Bucket = bucket,
64
+ Key = s3_key,
65
+ ExtraArgs = {"ContentType": content_type},
66
+ )
67
+ return f"https://{bucket}.s3.{s3_region}.amazonaws.com/{s3_key}"
0 commit comments