# Client\_max\_body\_size does not work for chunked uploading

**URL:** <https://discourse.jupyter.org/t/client-max-body-size-does-not-work-for-chunked-uploading/29665>\
**Category:** JupyterLab\
**Tags:** jupyterlab, help-wanted\
**Created:** [October 30, 2024, 1:21am UTC](https://discourse.jupyter.org/t/client-max-body-size-does-not-work-for-chunked-uploading/29665 "2024-10-30T01:21:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![wangzbo](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/wangzbo/32/14831_2.png) [@wangzbo](https://discourse.jupyter.org/u/wangzbo)\
**Post date:** [October 30, 2024, 1:21am UTC](https://discourse.jupyter.org/t/client-max-body-size-does-not-work-for-chunked-uploading/29665/1 "2024-10-30T01:21:09Z")

</div>

I am using JH on k8s(jupyterlab version 4.2.0) behind nginx. I just want the user to upload files with size less than 10M. So I added the configuration in nginx.conf “client\_max\_body\_size 10M”. However, this does not prevent users uploading files greater than 10M.

From the browser debug console, I can see that the file has been separated into chunks of size 1M, then they are sent to the sever side. I guess that’s why the nginx did not block this.

I see some relevant code in packages/filebrowser/src/model.ts:

```auto
export const CHUNK_SIZE = 1024 * 1024;
async upload(file: File): Promise<Contents.IModel> {
    // We do not support Jupyter Notebook version less than 4, and Jupyter
    // Server advertises itself as version 1 and supports chunked
    // uploading. We assume any version less than 4.0.0 to be Jupyter Server
    // instead of Jupyter Notebook.
    const serverVersion = PageConfig.getNotebookVersion();
    const supportsChunked =
      serverVersion < [4, 0, 0] /* Jupyter Server */ ||
      serverVersion >= [5, 1, 0]; /* Jupyter Notebook >= 5.1.0 */
    const largeFile = file.size > LARGE_FILE_SIZE;

    if (largeFile && !supportsChunked) {
      const msg = this._trans.__(
        'Cannot upload file (>%1 MB). %2',
        LARGE_FILE_SIZE / (1024 * 1024),
        file.name
      );
      console.warn(msg);
      throw msg;
    }

    const err = 'File not uploaded';
    if (largeFile && !(await this._shouldUploadLarge(file))) {
      throw 'Cancelled large file upload';
    }
    await this._uploadCheckDisposed();
    await this.refresh();
    await this._uploadCheckDisposed();
    if (
      this._items.find(i => i.name === file.name) &&
      !(await shouldOverwrite(file.name))
    ) {
      throw err;
    }
    await this._uploadCheckDisposed();
    const chunkedUpload = supportsChunked && file.size > CHUNK_SIZE;
    return await this._upload(file, chunkedUpload);
  }

```

My question is: Is there a config to set the chunk size bigger or a workaround to only allow users upload files with size \< 10M?

---

<div class="post-metadata">

**Author:** ![happy.every.day](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/happy.every.day/32/16376_2.png) [@happy.every.day](https://discourse.jupyter.org/u/happy.every.day)\
**Post date:** [September 18, 2025, 6:01am UTC](https://discourse.jupyter.org/t/client-max-body-size-does-not-work-for-chunked-uploading/29665/2 "2025-09-18T06:01:29Z")

</div>

I fixed this issue.

```auto
# Fix warning: Large file size warning: The file size is 34 MB. Do you still want to upload it?
cd /usr/local/share/jupyter/lab/static/
cp jlab_core.8aca991c1d97720da49a.js jlab_core.8aca991c1d97720da49a.js.bak.20250918
# const o=e.size>Ce
sed -i "s:const o=e.size>Ce:const o=false:g" jlab_core.8aca991c1d97720da49a.js

# Restart JupyterHub Service.

```
