Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+24
@@ -0,0 +1,24 @@
|
||||
import { redirect, type LoaderFunctionArgs } from "react-router";
|
||||
import { assertFileKeyBelongsToTenant } from "@hivegrid/storage";
|
||||
|
||||
import { auditPortalDocumentDownload, getPortalReleasedFile, portalNotFound, requirePortalSessionContext } from "~/services/customer-portal/portal-data.server";
|
||||
import { isFileScanDeliverable } from "~/utils/integrations/fileScanPolicy";
|
||||
import { createMediaDownloadUrl } from "~/utils/integrations/mediaSigning.server";
|
||||
import { recordAuthorizedStorageDownload } from "~/lib/metrics/storage-traffic";
|
||||
|
||||
export async function loader({ request, params }: LoaderFunctionArgs) {
|
||||
if (!params.releaseId) throw portalNotFound();
|
||||
const session = await requirePortalSessionContext(request, params.tenant);
|
||||
const { identity } = session;
|
||||
const file = await getPortalReleasedFile(identity, params.releaseId);
|
||||
if (!file || !isFileScanDeliverable(file.scanStatus)) throw portalNotFound();
|
||||
try {
|
||||
assertFileKeyBelongsToTenant(identity.tenantId, file.storageKey, "download");
|
||||
} catch {
|
||||
throw portalNotFound();
|
||||
}
|
||||
const signedUrl = await createMediaDownloadUrl({ key: file.storageKey, filename: file.displayName, ttlSeconds: 60 });
|
||||
await auditPortalDocumentDownload(identity, params.releaseId, request);
|
||||
recordAuthorizedStorageDownload({ surface: "portal_document", delivery: "signed_redirect", objectSizeBytes: null });
|
||||
throw redirect(signedUrl, { headers: session.responseHeaders });
|
||||
}
|
||||
Reference in new issue
Block a user