Skip to content

Commit fea3093

Browse files
fix: handle uncaught err of max upload pdf in form
1 parent 1cefe01 commit fea3093

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

apps/OpenSign/src/pages/Form.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ function Form() {
2828
}
2929

3030
const Forms = (props) => {
31+
const maxFileSize = 20;
3132
const navigate = useNavigate();
3233
const [signers, setSigners] = useState([]);
3334
const [folder, setFolder] = useState({ ObjectId: "", Name: "" });
@@ -56,17 +57,17 @@ const Forms = (props) => {
5657
try {
5758
let files = e.target.files;
5859
if (typeof files[0] !== "undefined") {
59-
const mb = Math.round(files[0].bytes / Math.pow(1024, 2));
60-
if (mb > 10) {
60+
const mb = Math.round(files[0].size / Math.pow(1024, 2));
61+
if (mb > maxFileSize) {
6162
alert(
62-
`The selected file size is too large. Please select a file less than ${Math.round(
63-
10
64-
)} MB`
63+
`The selected file size is too large. Please select a file less than ${maxFileSize} MB`
6564
);
65+
setFileUpload([]);
66+
e.target.value = "";
6667
return;
68+
} else {
69+
handleFileUpload(files[0]);
6770
}
68-
69-
handleFileUpload(files[0]);
7071
} else {
7172
alert("Please select file.");
7273
return false;
@@ -114,10 +115,10 @@ const Forms = (props) => {
114115
const url = file.link;
115116
const mb = Math.round(file.bytes / Math.pow(1024, 2));
116117

117-
if (mb > 10) {
118+
if (mb > maxFileSize) {
118119
setTimeout(() => {
119120
alert(
120-
`The selected file size is too large. Please select a file less than 10 MB`
121+
`The selected file size is too large. Please select a file less than ${maxFileSize} MB`
121122
);
122123
}, 500);
123124
return;

apps/OpenSignServer/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export const config = {
9595
},
9696
appId: process.env.APP_ID || 'myAppId',
9797
maxLimit: 500,
98+
maxUploadSize: '30mb',
9899
masterKey: process.env.MASTER_KEY, //Add your master key here. Keep it secret!
99100
masterKeyIps: ['0.0.0.0/0', '::/0'], // '::1'
100101
serverURL: process.env.SERVER_URL || 'http://localhost:8080/app', // Don't forget to change to https if needed

0 commit comments

Comments
 (0)