fix(pres_mgmt): switch direct download links to event_file endpoint

event_file ?key= auth fix is now deployed. Retire the hosted_file workaround
and use /v3/action/event_file/{event_file_id}/download?key=... as the canonical
form across the file downloads report, manage file list, and download button.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Scott Idem
2026-06-10 14:41:53 -04:00
parent 6b122a065e
commit 48bc52899f
3 changed files with 9 additions and 11 deletions

View File

@@ -186,12 +186,12 @@ let is_url_file = $derived.by(() => {
let direct_download_url = $derived.by(() => {
if (!show_direct_download || !hosted_file_obj) return '';
// Always use the hosted_file endpoint — it supports ?key= auth and resolves event_file
// IDs automatically via Redis. The event_file endpoint's ?key= support is not yet deployed.
const file_id =
hosted_file_obj.hosted_file_id ||
hosted_file_obj.event_file_id ||
hosted_file_id;
// Use event_file endpoint when event_file_id is present (canonical per API guide §5).
// Fall back to hosted_file endpoint for standalone hosted_file objects.
if (hosted_file_obj.event_file_id) {
return `${$ae_api.base_url}/v3/action/event_file/${hosted_file_obj.event_file_id}/download?filename=${ae_util.clean_filename(final_filename)}&key=${$ae_api.account_id}`;
}
const file_id = hosted_file_obj.hosted_file_id || hosted_file_id;
return `${$ae_api.base_url}/v3/action/hosted_file/${file_id}/download?filename=${ae_util.clean_filename(final_filename)}&key=${$ae_api.account_id}`;
});

View File

@@ -317,7 +317,7 @@ async function handle_convert_pdf_to_image(event_file_obj: key_val) {
</span>
<MyClipboard
value={encodeURI(
`${$ae_api.base_url}/v3/action/hosted_file/${event_file_obj?.hosted_file_id}/download?filename=${ae_util.clean_filename(event_file_obj?.filename)}&key=${$ae_api.account_id}`
`${$ae_api.base_url}/v3/action/event_file/${event_file_obj?.event_file_id}/download?filename=${ae_util.clean_filename(event_file_obj?.filename)}&key=${$ae_api.account_id}`
)}
btn_text="Copy Original"
btn_title="Copy the direct download link to the clipboard."
@@ -326,7 +326,7 @@ async function handle_convert_pdf_to_image(event_file_obj: key_val) {
<MyClipboard
value={encodeURI(
`${$ae_api.base_url}/v3/action/hosted_file/${event_file_obj?.hosted_file_id}/download?filename=${ae_util.clean_filename(event_file_obj?.event_session_code ?? '')}_${ae_util.clean_filename(event_file_obj?.event_presentation_name ?? event_file_obj?.event_session_name ?? '').substring(0, 30)}_${ae_util.clean_filename(event_file_obj?.event_presenter_full_name ?? '')}.${event_file_obj?.extension}&key=${$ae_api.account_id}`
`${$ae_api.base_url}/v3/action/event_file/${event_file_obj?.event_file_id}/download?filename=${ae_util.clean_filename(event_file_obj?.event_session_code ?? '')}_${ae_util.clean_filename(event_file_obj?.event_presentation_name ?? event_file_obj?.event_session_name ?? '').substring(0, 30)}_${ae_util.clean_filename(event_file_obj?.event_presenter_full_name ?? '')}.${event_file_obj?.extension}&key=${$ae_api.account_id}`
)}
btn_text="Copy Renamed"
btn_title="Copy the renamed download link to the clipboard. Format: [session-code]_[presentation-name]_[presenter-name].[ext]"

View File

@@ -124,10 +124,8 @@ function build_filename(file: any, fmt: FormatKey): string {
function build_download_url(file: any, fmt: FormatKey): string {
const fname = build_filename(file, fmt);
// Using hosted_file endpoint — event_file ?key= auth not yet deployed on backend.
// hosted_file resolves event_file IDs automatically and supports ?key= today.
return encodeURI(
`${$ae_api.base_url}/v3/action/hosted_file/${file.hosted_file_id}/download?filename=${ae_util.clean_filename(fname)}&key=${$ae_api.account_id}`
`${$ae_api.base_url}/v3/action/event_file/${file.event_file_id}/download?filename=${ae_util.clean_filename(fname)}&key=${$ae_api.account_id}`
);
}