mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
@@ -210,6 +210,9 @@ exports.issueToken = async (req, res) => {
|
|||||||
// 3. Requester IP matches the IP that issued the token
|
// 3. Requester IP matches the IP that issued the token
|
||||||
//
|
//
|
||||||
// Range requests for the same token are allowed (browser seeking).
|
// Range requests for the same token are allowed (browser seeking).
|
||||||
|
// TEMPORARY:
|
||||||
|
// Same with problem from s3.service.js (Line 168-171)
|
||||||
|
// Investigate the issue ourselves.
|
||||||
|
|
||||||
exports.streamAsset = async (req, res) => {
|
exports.streamAsset = async (req, res) => {
|
||||||
const { token } = req.params;
|
const { token } = req.params;
|
||||||
@@ -257,6 +260,7 @@ exports.streamAsset = async (req, res) => {
|
|||||||
let presignedUrl;
|
let presignedUrl;
|
||||||
try {
|
try {
|
||||||
presignedUrl = await s3.getSignedDownloadUrl(storage_key, 60);
|
presignedUrl = await s3.getSignedDownloadUrl(storage_key, 60);
|
||||||
|
console.log("Presigned URL:", presignedUrl);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("[CLIENT][MEDIA][STREAM] Pre-sign failed:", err.message);
|
console.error("[CLIENT][MEDIA][STREAM] Pre-sign failed:", err.message);
|
||||||
return res.status(500).json({ message: "Could not resolve media stream." });
|
return res.status(500).json({ message: "Could not resolve media stream." });
|
||||||
|
|||||||
+13
-4
@@ -165,15 +165,24 @@ async function deleteFile(key) {
|
|||||||
// A presigned URL arriving there collides with the proxy's own signature and
|
// A presigned URL arriving there collides with the proxy's own signature and
|
||||||
// Garage rejects the request (400 "Header `x-amz-date` should be signed").
|
// Garage rejects the request (400 "Header `x-amz-date` should be signed").
|
||||||
// See getPublicUrl() below for the browser-facing equivalent.
|
// See getPublicUrl() below for the browser-facing equivalent.
|
||||||
|
// TEMPORARY:
|
||||||
|
// The problem is this line do not tell for each of development machines
|
||||||
|
// which ones should be called whether it's for PUBLIC_URL or LOCAL_ENDPOINT itself.
|
||||||
//
|
//
|
||||||
async function getSignedDownloadUrl(key, expiresInSeconds = 3600) {
|
async function getSignedDownloadUrl(key, expiresInSeconds = 3600) {
|
||||||
|
const client = getPublicClient();
|
||||||
|
|
||||||
return getSignedUrl(
|
return getSignedUrl(
|
||||||
s3,
|
client,
|
||||||
new GetObjectCommand({ Bucket: DEFAULT_BUCKET, Key: key }),
|
new GetObjectCommand({
|
||||||
{ expiresIn: expiresInSeconds }
|
Bucket: DEFAULT_BUCKET,
|
||||||
|
Key: key,
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
expiresIn: expiresInSeconds,
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── getPublicUrl ─────────────────────────────────────────────────────────────
|
// ─── getPublicUrl ─────────────────────────────────────────────────────────────
|
||||||
//
|
//
|
||||||
// Browser-facing pre-signed GET URL, signed against S3_PUBLIC_URL. Safe again
|
// Browser-facing pre-signed GET URL, signed against S3_PUBLIC_URL. Safe again
|
||||||
|
|||||||
Reference in New Issue
Block a user