mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
+17
-7
@@ -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 ────────────────────────────────────────────────────────
|
||||||
|
|||||||
Reference in New Issue
Block a user