Skip to content

Override upload file max size in mb #2370

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

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

Conversation

MuPp3t33r
Copy link

For attention to @bradenmacdonald to review if this PR meets requirements.

Description

This update makes the following changes:
constants.js:

  • Fix incorrect comment for 20MB default file upload limit
  • Retain the default 20MB limit but use an override (if exists) from GetConfig, allowing users to specify an override value via MFE_CONFIG API
  • Validation that the value entered is a valid and positive integer (use default in case something goes horribly wrong)
  • Written as a function allowing it to be called by other components

FilePage.jsx:

  • Remove the hardcoded maxFileSize value and instead import it from constants.js

ModalDropzone.jsx:

  • Removed UPLOAD_FILE_MAX_SIZE constants that were defined and replaced with a call to the new function in constants.js

TextbookForm.jsx:

  • Removed UPLOAD_FILE_MAX_SIZE constants that were defined and replaced with a call to the new function in constants.js

Imports from constants now use the updated new format '@src/constants' instead of the old '../../constants'

Supporting information

this is an improvement to my previous attempt before i really knew what i was doing, now I only know a little bit of what I'm doing :)

Testing instructions

  1. Replace this MFE using a plugin:
from tutormfe.hooks import MFE_APPS

@MFE_APPS.add()
def _override_authoring_mfe(mfes):
    mfes["authoring"] = {
        "repository": "https://github.com/MuPp3t33r/frontend-app-authoring.git",
        "version": "OVERRIDE_UPLOAD_FILE_MAX_SIZE_IN_MB", 
        "port": 2001, 
    }
    return mfes

  1. Rebuild your MFE
  • tutor images build mfe
  1. Apply the patched values to override the config.
    Note that this must be done in MFE_CONFIG and in the CaddyFile to allow Caddy to process your larger requests
    Here is a sample plugin allowing user to provide one input for the value and it applies in both locations
from tutor import hooks

# Instructions / info
# override_value is defined as a string so bad formats (incorrectly entered values) don't crash Python immediately
# User MUST enter only digits as a POSITIVE integer representing a value in MegaBytes (MB), e.g. "1024" for 1GB
# This adds the value to the MFE_Config API as well as the CaddyFile CMS block

override_value = "1024"  

# --- Validation ---
try:
    override_int = int(override_value)
    if override_int <= 0:
        raise ValueError
except ValueError:
    raise ValueError(
        f"Invalid override_value: {override_value}. "
        "It must be a positive integer without units (e.g., 1048)."
    )

# --- Config patches ---
hooks.Filters.ENV_PATCHES.add_items([
    (
        "openedx-lms-production-settings",
        f"""
MFE_CONFIG["OVERRIDE_UPLOAD_FILE_MAX_SIZE_IN_MB"] = "{override_int}"
"""
    ),
])

hooks.Filters.ENV_PATCHES.add_item(
    (
        "caddyfile-cms",
        f"""
# Maximum asset upload size in CMS/Studio
handle /assets/* {{
    request_body {{
        max_size {override_int}MB
    }}
}}
        """
    )
)

  1. Finally - enable the override plugin and restart your instance:
  • tutor plugins enable override_max_asset_upload_size
  • tutor local stop && tutor local start -d

Now, under the following menus:

  • Content -> Files
  • Content -> Pages & Resources -> Textbooks
    You will find that you can upload files up to whatever maximum defined in the override_max_asset_upload_size plugin

@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels Aug 11, 2025
@openedx-webhooks
Copy link

Thanks for the pull request, @MuPp3t33r!

This repository is currently maintained by @bradenmacdonald.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.


Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core contributor PR author is a Core Contributor (who may or may not have write access to this repo). open-source-contribution PR author is not from Axim or 2U
Projects
Status: Needs Triage
Development

Successfully merging this pull request may close these issues.

2 participants