[PB-6328/PB-6333]: feat/validate file size before upload#1957
Conversation
Deploying drive-web with
|
| Latest commit: |
1a1063b
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://a956d774.drive-web.pages.dev |
| Branch Preview URL: | https://feature-max-file-size-limit.drive-web.pages.dev |
…le-size-limit-per-tier
…le-size-limit-per-tier
…le-size-limit-per-tier
|
|
||
| return { | ||
| isAuthenticated: state.user.isAuthenticated, | ||
| maxUploadFileSize: state.fileVersions.limits?.maxUploadFileSize ?? undefined, |
There was a problem hiding this comment.
I know it looks a bit weird to get the max upload file size from fileVersions.limit. The issue is that this value actually represents the user's Drive limits based on their tier, but when it was originally introduced it was named fileVersions.limits instead of driveLimits or smth like that. We should eventually refactor this and rename it to something more generic, like limits, to better reflect its real purpose.
It will be done in another PR so we don't go out of scope.
| }), | ||
| ); | ||
|
|
||
| const openReachedPlanLimitDialog = () => { |
There was a problem hiding this comment.
Can we make it a common constant for both?
| rootFolderItem ??= createdFolder; | ||
|
|
||
| if (!rootFolderData) { | ||
| rootFolderData = createdFolder; |
There was a problem hiding this comment.
we already did rootFolderItem ??= createdFolder; just a line before, this if won't help
There was a problem hiding this comment.
rootFolderItem and rootFolderData are different
There was a problem hiding this comment.
ops, you are right, it's another one
| expect(uploadItemsParallelThunk).toHaveBeenCalledWith(expect.objectContaining({ files: [smallFile, bigFile] })); | ||
| }); | ||
|
|
||
| test('When no size limit is configured, then all files are uploaded regardless of size', async () => { |
There was a problem hiding this comment.
Don't we have some max limit for all to use instead of infinite?
There was a problem hiding this comment.
Yeah, I can limit it to 40GB as default (the max size we currently have right now in prod).
| }); | ||
|
|
||
| test('When no size limit is configured, then all files are uploaded regardless of size', async () => { | ||
| test('When no size limit is configured, then all files above the default size limit are uploaded', async () => { |
There was a problem hiding this comment.
maybe below and not above?
| } | ||
|
|
||
| const allowedFilesToUpload = validateFileSize(dispatch, files, maxFileSize); | ||
| const allowedFilesToUpload = validateFileSize(dispatch, files, maxFileSize as number); |
There was a problem hiding this comment.
Sonar says no need for 'as number'
|



Description
Implemented a pre-validation step before starting uploads to filter out files that exceed the maximum upload size allowed for the user’s current tier.
If a file is larger than the allowed limit, a dialog is displayed informing the user about:
This prevents invalid uploads from starting and provides clearer upgrade guidance to the user.
Related Issues
Related Pull Requests
Checklist
Testing Process
Additional Notes
This can be safely merged. If the server does not provide a
maxFileSizeLimit, we allow the upload. The backend will check the file size limit if needed. So, this not affects to the current flow fn until we activate the limit in the backend.