Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(upload): Fix total documents size limit calculation #7843

Open
wants to merge 1 commit into
base: release-v1.6.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,17 @@ export const DocumentUploaderWithOption = (props: IFullProps) => {
(option: ISelectOption) => option.value === documentType
)

const options = { ...defaultOptions }
const resizedImage =
Boolean(options.maxSizeMB) &&
bytesToMB(uploadedImage.size) > options.maxSizeMB &&
(await imageCompression(uploadedImage, options))

Comment on lines +225 to +229
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you for your contribution! @nifaliana 🙏🏼
I think your approach is correct, I wonder if there is any alternative other than compressing image second time to obtain the file size. One way could be utilizing the output of the processImage function with a small refactor. What do you think?

const newDocument: IFileValue = {
optionValues,
type: uploadedImage.type,
type: resizedImage.type || uploadedImage.type,
data: fileAsBase64.toString(),
fileSize: uploadedImage.size
fileSize: resizedImage.size || uploadedImage.size
}

props.onComplete([...props.files, newDocument])
Expand Down