Skip to content

Commit

Permalink
Add config option to restrict import file size
Browse files Browse the repository at this point in the history
  • Loading branch information
taylortom authored Nov 8, 2024
1 parent 22915ba commit 709b3df
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions conf/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
"frameworkRepository": {
"description": "URL of the Adapt framework git repository to install",
"type": "string"
},
"importMaxFileSize": {
"description": "Maximum file upload size for course imports",
"type": "string",
"isBytes": true,
"default": "500mb"
}
}
}
4 changes: 2 additions & 2 deletions lib/AdaptFrameworkUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,12 @@ class AdaptFrameworkUtils {
* @return {Promise}
*/
static async handleImportFile (req, res) {
const middleware = await App.instance.waitForModule('middleware')
const [fw, middleware] = await App.instance.waitForModule('adaptframework', 'middleware')
const handler = req.get('Content-Type').indexOf('multipart/form-data') === 0
? middleware.fileUploadParser
: middleware.urlUploadParser
return new Promise((resolve, reject) => {
handler(middleware.zipTypes, { unzip: true })(req, res, e => e ? reject(e) : resolve())
handler(middleware.zipTypes, { maxFileSize: fw.getConfig('importMaxFileSize'), unzip: true })(req, res, e => e ? reject(e) : resolve())
})
}
}
Expand Down

0 comments on commit 709b3df

Please sign in to comment.