add: ver()

Signed-off-by: Kenneth Obsequio <k80308392@gmail.com>
This commit is contained in:
2026-07-08 12:11:03 +08:00
parent bb7e8fde08
commit 8c55b61e29
+17 -7
View File
@@ -176,14 +176,24 @@ async function getSignedDownloadUrl(key, expiresInSeconds = 3600) {
// ─── getPublicUrl ───────────────────────────────────────────────────────────── // ─── getPublicUrl ─────────────────────────────────────────────────────────────
// //
// Browser-facing object URL, unsigned. garage-anon-proxy (fronting // Browser-facing pre-signed GET URL, signed against S3_PUBLIC_URL. Safe again
// S3_PUBLIC_URL) authenticates every request server-side with real // now that garage-anon-proxy detects a valid query-string SigV4 signature and
// credentials, so a client-side presign adds nothing but a broken request — // forwards it unmodified instead of re-signing on top of it (see
// see getSignedDownloadUrl() above. Use this wherever a URL is handed // isPresignedRequest() in garage-anon-proxy/server.js) — that mismatch used to
// directly to the browser (e.g. thumbnail previews). // produce Garage's 400 "Header `x-amz-date` should be signed". Use this
// wherever a URL is handed directly to the browser (e.g. thumbnail previews).
// //
async function getPublicUrl(key, bucket = DEFAULT_BUCKET) { // expiresInSeconds defaults to 4h to outlive the longest cache window a caller
return buildPublicUrl(key, bucket); // hands this URL out under (client media token TTL — see media.controller.js),
// so a cached thumbnail_url never outlives its own signature.
//
async function getPublicUrl(key, bucket = DEFAULT_BUCKET, expiresInSeconds = 4 * 60 * 60) {
const client = getPublicClient();
return getSignedUrl(
client,
new GetObjectCommand({ Bucket: bucket, Key: key }),
{ expiresIn: expiresInSeconds }
);
} }
// ─── getObjectStream ──────────────────────────────────────────────────────── // ─── getObjectStream ────────────────────────────────────────────────────────