forked from mtusi2026/mtusi2026lab4
11 lines
638 B
Python
11 lines
638 B
Python
#!/usr/bin/env python3
|
|
"""TEST-ONLY helper: puts an orphan object (as if the API died between S3 PUT and COMMIT)."""
|
|
import os, secrets, boto3
|
|
from botocore.config import Config
|
|
s3 = boto3.client("s3", endpoint_url=os.environ["S3_ENDPOINT"], region_name=os.getenv("S3_REGION", "us-east-1"),
|
|
aws_access_key_id=os.environ["S3_ACCESS_KEY_ID"], aws_secret_access_key=os.environ["S3_SECRET_ACCESS_KEY"],
|
|
config=Config(signature_version="s3v4", s3={"addressing_style": "path"}))
|
|
key = "attachments/" + secrets.token_hex(16)
|
|
s3.put_object(Bucket=os.environ["S3_BUCKET"], Key=key, Body=b"orphan-test", ContentType="image/png")
|
|
print(key)
|