Skip to content

Commit

Permalink
Make Uppy file upload limits configurable in app .env
Browse files Browse the repository at this point in the history
  • Loading branch information
ml-evs committed Oct 28, 2023
1 parent 8ceae6d commit 88d13bf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 3 additions & 3 deletions webapp/src/file_upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ import Webcam from "@uppy/webcam";
import store from "@/store/index.js";
import { construct_headers } from "@/server_fetch_utils.js";

import { API_URL } from "@/resources.js";
import { API_URL, UPPY_MAX_NUMBER_OF_FILES, UPPY_MAX_TOTAL_FILE_SIZE } from "@/resources.js";
// file-upload loaded

export default function setupUppy(item_id, trigger_selector, reactive_file_list) {
console.log("setupUppy called with: " + trigger_selector);
var uppy = new Uppy({
restrictions: {
// Somewhat arbitrary restrictions that prevent numbers that would break the server in one go -- the API should also refuse files when 'full'
maxTotalFileSize: 102400000000, // Set this UI restriction arbitrarily high at 100 GB for now --- this is the point at which I would be unsure if the upload could even complete
maxNumberOfFiles: 10000, // Similarly, a max of 10000 files in one upload as a single "File" entry feels reasonable, once we move to uploading folders etc.
maxTotalFileSize: UPPY_MAX_TOTAL_FILE_SIZE, // Set this UI restriction arbitrarily high at 100 GB for now --- this is the point at which I would be unsure if the upload could even complete
maxNumberOfFiles: UPPY_MAX_NUMBER_OF_FILES, // Similarly, a max of 10000 files in one upload as a single "File" entry feels reasonable, once we move to uploading folders etc.
},
});
let headers = construct_headers();
Expand Down
9 changes: 9 additions & 0 deletions webapp/src/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ export const LOGO_URL = process.env.VUE_APP_LOGO_URL;
export const HOMEPAGE_URL = process.env.VUE_APP_HOMEPAGE_URL;
export const GRAVATAR_STYLE = "identicon";

export const UPPY_MAX_TOTAL_FILE_SIZE =
Number(process.env.VUE_APP_UPPY_MAX_TOTAL_FILE_SIZE) != null
? process.env.VUE_APP_UPPY_MAX_TOTAL_FILE_SIZE
: 102400000000;
export const UPPY_MAX_NUMBER_OF_FILES =
Number(process.env.VUE_APP_UPPY_MAX_NUMBER_OF_FILES) != null
? process.env.VUE_APP_UPPY_MAX_NUMBER_OF_FILES
: 10000;

export const debounceTime = 250; // time after user stops typing before request is sent

export const blockTypes = {
Expand Down

0 comments on commit 88d13bf

Please sign in to comment.