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

#10770: Vector files import limits #10772

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mahmoudadel54
Copy link
Contributor

Description

This PR handles checking on imported vector files size if a confugrable prop is existing into localConfig.
This PR introduces a performed check by MS to verify if imported vector files are over a certain (configurable) file size.

The size limit is allowed now to be configurable into localConfig by prop called 'importedVectorFileMaxSizeInMB' and its value is number of megabytes. If the file is exceeding the max limit, a warning notification is shown to user.

Please check if the PR fulfills these requirements

What kind of change does this PR introduce? (check one with "x", remove the others)

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe: Enhancement

Issue

#10770

What is the current behavior?
#10770

What is the new behavior?
If 'importedVectorFileMaxSizeInMB' is added into localConfig, and user wants to upload vector files with size larger that 'importedVectorFileMaxSizeInMB' it will show a warning notification about exceeding the max file size.

2025-01-22.21-55-56.mp4

Breaking change

Does this PR introduce a breaking change? (check one with "x", remove the other)

  • Yes, and I documented them in migration notes
  • No

Other useful information

@mahmoudadel54 mahmoudadel54 added this to the 2025.01.00 milestone Jan 24, 2025
@mahmoudadel54 mahmoudadel54 requested a review from MV88 January 24, 2025 15:58
@mahmoudadel54 mahmoudadel54 self-assigned this Jan 24, 2025
Copy link
Member

@tdipisa tdipisa left a comment

Choose a reason for hiding this comment

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

@mahmoudadel54 please update this PR by aligning it to master branch.

Description:
- handle checking the file size for imported vector layers only
- show a warning notification for each layer has size larger than the configurable limit if configured
- add translations
- add test units
Description:
- add enhancements to the code including some helpful comments
Description:
- rename the configurable prop name of vector max size to 'importedVectorFileMaxSizeInMB' instead of 'importedVectorFileSizeInMB' to be more meaningful
@mahmoudadel54
Copy link
Contributor Author

@mahmoudadel54 please update this PR by aligning it to master branch.

Done

@tdipisa tdipisa linked an issue Jan 31, 2025 that may be closed by this pull request
@tdipisa tdipisa removed their request for review January 31, 2025 10:15
@@ -66,6 +67,16 @@ const checkFileType = (file) => {
const readFile = (onWarnings) => (file) => {
const ext = recognizeExt(file.name);
const type = file.type || MIME_LOOKUPS[ext];
// Check the file size first before file conversion process to avoid this useless effort
const configurableFileSizeLimitInMB = getConfigProp('importedVectorFileMaxSizeInMB');
Copy link
Contributor

@MV88 MV88 Feb 6, 2025

Choose a reason for hiding this comment

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

what is the default limit ? i think we need to force one default value and not leave it without any limit.
if it was not decided we can make 2 MB

Also i think is better to have this prop as part of MapImport plugin

Copy link
Contributor

Choose a reason for hiding this comment

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

@tdipisa do you agree ?

Copy link
Contributor

Choose a reason for hiding this comment

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

@MV88 @mahmoudadel54 just a note, I did a test and it seems possible to pass the max size property as cfg of MapImport, I modified following files:

export default compose(
    processFiles,
    useFiles,
    dropZoneHandlers
)(
    ({
        onClose = () => {},
        onDrop = () => {},
        onRef = () => {},
        ...props
    }) => <DragZone
        onClose={onClose}
        onDrop={(files) => onDrop({ files, options: { importedVectorFileMaxSizeInMB: props.importedVectorFileMaxSizeInMB } })}
        onRef={onRef}
    >
        <Content {...props} />
    </DragZone>);
               drop$.switchMap(
                    ({ files, options }) => Rx.Observable.from(files)
                        .flatMap(checkFileType) // check file types are allowed
                        .flatMap(readFile({ onWarnings, options })) // read files to convert to json

could you give it a try before using the getConfigProp ?

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

Successfully merging this pull request may close these issues.

Vector files import limits
4 participants