summaryrefslogtreecommitdiff
path: root/paste/s3.py
diff options
context:
space:
mode:
authorJohn Turner <jturner.usa@gmail.com>2025-09-05 18:59:55 -0400
committerJohn Turner <jturner.usa@gmail.com>2025-09-05 18:59:55 -0400
commite9322689860bf6f7266c1caef17d25e201a3568d (patch)
tree9bc5379f59ac3e7393f9ba3834e354e3715e6b18 /paste/s3.py
parent24c69c29149526b46c01a7e1f99d873e1dbdb8bf (diff)
downloadpypaste-e9322689860bf6f7266c1caef17d25e201a3568d.tar.gz
rename to pypaste
"paste" conflicts with a linux command that everyone probably has by default.
Diffstat (limited to 'paste/s3.py')
-rw-r--r--paste/s3.py105
1 files changed, 0 insertions, 105 deletions
diff --git a/paste/s3.py b/paste/s3.py
deleted file mode 100644
index 673e428..0000000
--- a/paste/s3.py
+++ /dev/null
@@ -1,105 +0,0 @@
-from datetime import datetime, UTC
-from typing import Dict
-from dataclasses import dataclass
-from bozo4 import s3v4_sign_request, s3v4_datetime_string
-
-
-@dataclass
-class Request:
- url: str
- headers: Dict[str, str]
-
-
-@dataclass
-class Bucket:
- endpoint: str
- region: str
- bucket: str
- access_key: str
- secret_key: str
-
- def get(self, key: str) -> Request:
- now = datetime.now(UTC)
-
- headers = {
- "Host": self.endpoint,
- "X-Amz-Date": s3v4_datetime_string(now),
- "X-Amz-Content-SHA256": "UNSIGNED-PAYLOAD",
- }
-
- auth = s3v4_sign_request(
- endpoint=self.endpoint,
- region=self.region,
- access_key=self.access_key,
- secret_key=self.secret_key,
- request_method="GET",
- date=now,
- payload_hash="UNSIGNED-PAYLOAD",
- uri=f"/{self.bucket}/{key}",
- parameters={},
- headers=headers,
- service="s3",
- )
-
- headers["Authorization"] = auth
-
- return Request(f"https://{self.endpoint}/{self.bucket}/{key}", headers)
-
- def put(
- self, key: str, content_length: int, content_type: str, payload_hash: str
- ) -> Request:
- now = datetime.now(UTC)
-
- headers = {
- "Host": self.endpoint,
- "X-Amz-Date": s3v4_datetime_string(now),
- "X-Amz-Content-SHA256": payload_hash,
- "Content-Length": str(content_length),
- "Content-Type": content_type,
- }
-
- auth = s3v4_sign_request(
- endpoint=self.endpoint,
- region=self.region,
- access_key=self.access_key,
- secret_key=self.secret_key,
- request_method="PUT",
- date=now,
- payload_hash=payload_hash,
- uri=f"/{self.bucket}/{key}",
- parameters={},
- headers=headers,
- service="s3",
- )
-
- headers["Authorization"] = auth
-
- return Request(f"https://{self.endpoint}/{self.bucket}/{key}", headers)
-
- def delete(self, key: str) -> Request:
- now = datetime.now(UTC)
-
- headers = {
- "Host": self.endpoint,
- "X-Amz-Date": s3v4_datetime_string(now),
- "X-Amz-Content-SHA256": "UNSIGNED-PAYLOAD",
- "Content-Length": "0",
- }
-
- auth = s3v4_sign_request(
- endpoint=self.endpoint,
- region=self.region,
- access_key=self.access_key,
- secret_key=self.secret_key,
- request_method="DELETE",
- date=now,
- payload_hash="UNSIGNED-PAYLOAD",
- uri=f"/{self.bucket}/{key}",
- parameters={},
- headers=headers,
- service="s3",
- )
-
- headers["Authorization"] = auth
-
- return Request(f"https://{self.endpoint}/{self.bucket}/{key}", headers)