ImageStudio Maintainer Claude Sonnet 4.6 commited on
Commit
f0b2701
Β·
1 Parent(s): 3c4970c

feat: restructure R2 key to namespace/uid/timestamp-rand format

Browse files
Files changed (1) hide show
  1. r2_uploader.py +3 -2
r2_uploader.py CHANGED
@@ -2,7 +2,7 @@
2
 
3
  Reads R2 credentials from the ``SCONFIG`` Space secret (a JSON blob) and uploads
4
  generated assets to a preset bucket. Object keys follow
5
- ``<yyyymmddhhmmss>-<namespace>-<rand>.<ext>``; the prompt and request params are
6
  attached as JSON object metadata so the owner can trace any asset back to the
7
  request that produced it.
8
 
@@ -255,7 +255,8 @@ def upload_asset(
255
  with open(path, "rb") as fh:
256
  data = fh.read()
257
 
258
- filekey = f"{_now_stamp()}-{namespace}-{uuid.uuid4().hex[:8]}{ext}"
 
259
 
260
  s3 = _client(cfg)
261
  _ensure_bucket(s3, bucket)
 
2
 
3
  Reads R2 credentials from the ``SCONFIG`` Space secret (a JSON blob) and uploads
4
  generated assets to a preset bucket. Object keys follow
5
+ ``<namespace>/<uid>/<yyyymmddhhmmss>-<rand>.<ext>``; the prompt and request params are
6
  attached as JSON object metadata so the owner can trace any asset back to the
7
  request that produced it.
8
 
 
255
  with open(path, "rb") as fh:
256
  data = fh.read()
257
 
258
+ safe_uid = uid or "anonymous"
259
+ filekey = f"{namespace}/{safe_uid}/{_now_stamp()}-{uuid.uuid4().hex[:8]}{ext}"
260
 
261
  s3 = _client(cfg)
262
  _ensure_bucket(s3, bucket)