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

feat(clone): allow maxSize limit to prevent downloading huge assets (videos) when cloning as site #31592

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

wezell
Copy link
Contributor

@wezell wezell commented Mar 12, 2025

This pull request introduces a new feature to limit the size of assets included in ZIP files during export operations. The changes include adding a new parameter for maximum file size, maxSize updating various methods to handle this parameter, and creating a utility class for size conversion.

Usages:
?maxSize=1g gb
?maxSize=10m mb
?maxSize=3mb mb
?maxSize=512k kb
?maxSize=10240 bytes

Key Changes

New Feature: Maximum File Size for Assets

  • dotCMS/src/main/java/com/dotcms/rest/api/v1/maintenance/MaintenanceResource.java:

    • Added maxSize parameter to methods downloadAssets, downloadStarter, and downloadStarterWithAssets. Incorporated SizeUtil.convertToBytes to convert the size string to bytes and pass it to the export methods. [1] [2] [3]
  • dotCMS/src/main/java/com/dotcms/util/SizeUtil.java:

    • Introduced SizeUtil class with a method convertToBytes to convert human-readable size strings (e.g., "1mb", "512k") to bytes.

Updates to Export Functionality

  • dotCMS/src/main/java/com/dotmarketing/portlets/cmsmaintenance/util/AssetFileNameFilter.java:

    • Modified AssetFileNameFilter constructor to accept a maxFileSize parameter and updated the accept method to filter out files exceeding the specified size. [1] [2]
  • dotCMS/src/main/java/com/dotmarketing/util/starter/ExportStarterUtil.java:

    • Updated methods streamCompressedStarter and streamCompressedAssets to accept maxFileSize and pass it to the streamCompressedData method. [1] [2]

User Interface Enhancements

  • dotCMS/src/main/webapp/html/portlet/ext/cmsmaintenance/view_cms_maintenance.jsp:
    • Added a new input field for the maximum file size in the asset export dialog, with validation for the size format.

@wezell wezell linked an issue Mar 12, 2025 that may be closed by this pull request
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.

Limit filesize when Downloading assets
1 participant