Skip to content

Conversation

@EmilFattakhov
Copy link
Member

Summary

  • Forces anonymous downloads for files ≤ NEXT_PUBLIC_MAX_ANONYMOUS_DOWNLOAD_SIZE (defaults to 100 MiB), even when a user session exists.
  • Forces authorized downloads for files > NEXT_PUBLIC_MAX_ANONYMOUS_DOWNLOAD_SIZE, using the existing session.
  • For unauthenticated users attempting a large download, shows: “Downloading large files require authorization, please login via gauth, wallet, github or discord”
  • Surfaces real download errors in the download modal (instead of a generic message).

Behavior

  • Small files (≤ threshold): always use anonymous backend path (downloadObjectByAnonymous).
  • Large files (> threshold): require session and use authorized backend path (downloadObjectByUser).

Changes

  • apps/frontend/src/services/download.ts: size-based branching + session requirement for large downloads.
  • apps/frontend/src/services/api.ts: add authMode to force anonymous vs session-backed download requests.
  • apps/frontend/src/components/molecules/ObjectDownloadModal.tsx: display actual thrown error message.

@netlify
Copy link

netlify bot commented Jan 9, 2026

Deploy Preview for auto-drive-storage ready!

Name Link
🔨 Latest commit a343aba
🔍 Latest deploy log https://app.netlify.com/projects/auto-drive-storage/deploys/696504f4b3725a0008dbebbb
😎 Deploy Preview https://deploy-preview-578--auto-drive-storage.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

const MiB = 1024 * 1024;
const MAX_CACHEABLE_FILE_SIZE = 150 * MiB;
const MAX_ANONYMOUS_DOWNLOAD_SIZE = Number(
process.env.NEXT_PUBLIC_MAX_ANONYMOUS_DOWNLOAD_SIZE ?? 100 * MiB,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a new environment variable? Added to the relevant places?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is initially how I was going to approach this, via setting up a new ENV variable. The original MAX_ANONYMOUS_DOWNLOAD_SIZE is coming from backend and not directly accessible on frontend, hence why I initially introduced a new env variable.

Now I'm thinking that is likely an incorrect approach - that would require us to maintain essentially the same variable in two places, which is a bad practice. I have adjusted the code to take another approach and eliminate this issue. Please review the latest commit.

TLDR: The frontend now always starts the download as an anonymous request (no auth headers) and lets the backend decide if the file is too big for anonymous downloads. If the backend rejects it as “too large/402”, the frontend retries with your logged-in session (or shows a “please login” message if you’re not signed in).

EmilFattakhov and others added 2 commits January 12, 2026 09:04
Co-authored-by: Jim Counter <jimcounter@hotmail.com>
Copy link
Member

@jim-counter jim-counter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having the config and behaviour propagate from the backend is cleaner. Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants