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: Validate max file size for attachments #149

Closed
wants to merge 5 commits into from

Conversation

astridbNHN
Copy link
Collaborator

Uses questionaire item to set the max file size to validate with Dropzone.

Default is 4MB

@@ -118,7 +123,7 @@ function getErrorMessage(
if (!mimeTypeIsValid(file, validFileTypes)) {
return resources.validationFileType;
} else if (!sizeIsValid(file, maxFileSize)) {
return resources.validationFileMax;
return resources.validationFileMax.replace('25', (maxFileSize / 1024 / 1024).toString());
Copy link
Collaborator

@AG-83 AG-83 Jan 24, 2024

Choose a reason for hiding this comment

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

Er ikke helt sikker at det er lurt at gjøre det hit. Er det ikke HN-Skjema sender i riktig format til refero. Kanskje det trenger ikke gjøre noe endring i feilmeldingen

@@ -118,7 +123,7 @@ function getErrorMessage(
if (!mimeTypeIsValid(file, validFileTypes)) {
return resources.validationFileType;
} else if (!sizeIsValid(file, maxFileSize)) {
return resources.validationFileMax;
return resources.validationFileMax.replace('25', (maxFileSize / 1024 / 1024).toString());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Vi har denne i HN-Skjema
skjemaResources.validationFileMax = skjemaResources.validationFileMax.replace(
'{0}',
DEFAULT_MAX_ATTACHMENT_FILE_SIZE_HN_SKJEMA_MB.toString()
);

});
const question: QuestionnaireItem = {
linkId: '4c71df6e-d743-46ba-d81f-f62777ffddb4',
type: 'attachment',
Copy link
Collaborator

@AG-83 AG-83 Jan 24, 2024

Choose a reason for hiding this comment

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

Det er ikke veldig viktig men man kan bruke
import itemType from '../constants/itemType';
type: itemType.ATTATCHMENT

@einett2039121
Copy link
Collaborator

Duplicate of new PR

@AG-83 AG-83 deleted the astridb/316660_maxfilstr_attachment branch February 27, 2024 07:51
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.

4 participants