Skip to content

Commit

Permalink
Survey import: increment max file size limit (only for system admins) (
Browse files Browse the repository at this point in the history
…#3400)

* allow importing survey files > 1GB (only system admin)

* use latest arena-server version

---------

Co-authored-by: Stefano Ricci <SteRiccio@users.noreply.github.com>
  • Loading branch information
SteRiccio and SteRiccio committed Apr 30, 2024
1 parent d9c38ed commit 7de00be
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 37 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
"@mui/x-data-grid": "^6.19.5",
"@mui/x-date-pickers": "^6.19.5",
"@openforis/arena-core": "^0.0.188",
"@openforis/arena-server": "^0.1.32",
"@openforis/arena-server": "^0.1.33",
"@reduxjs/toolkit": "^2.2.1",
"@sendgrid/mail": "^8.1.1",
"@shopify/draggable": "^1.1.3",
Expand Down
4 changes: 3 additions & 1 deletion server/system/appCluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ import * as RecordPreviewCleanup from './schedulers/recordPreviewCleanup'
import * as TempFilesCleanup from './schedulers/tempFilesCleanup'
import * as UserResetPasswordCleanup from './schedulers/userResetPasswordCleanup'

const fileSizeLimit = 2 * 1024 * 1024 * 1024 // 2GB

export const run = async () => {
const logger = Log.getLogger('AppCluster')

logger.info('server initialization start')

const arenaApp = await ArenaServer.init()
const arenaApp = await ArenaServer.init({ fileSizeLimit })
const { express: app } = arenaApp

if (ProcessUtils.isEnvDevelopment) {
Expand Down
9 changes: 8 additions & 1 deletion webapp/components/survey/SurveyCreate/SurveyCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,18 @@ import { Button, Dropzone, ProgressBar, RadioButtonGroup } from '@webapp/compone

import { createTypes, importSources, useCreateSurvey } from './store'
import { SurveyDropdown } from '../SurveyDropdown'
import { useUserIsSystemAdmin } from '@webapp/store/user'

const fileMaxSizeDefault = 1000 // 1GB
const fileMaxSizeSystemAdmin = 2000 // 2GB

const SurveyCreate = (props) => {
const { showImport, submitButtonLabel, template } = props

const surveyInfo = useSurveyInfo()
const i18n = useI18n()
const navigate = useNavigate()
const isSystemAdmin = useUserIsSystemAdmin()

const { newSurvey, onUpdate, onCreate, onImport, onCreateTypeUpdate, onFilesDrop, onOptionChange, onSourceChange } =
useCreateSurvey({
Expand All @@ -59,6 +64,8 @@ const SurveyCreate = (props) => {
navigate(appModuleUri(homeModules.dashboard))
}, [Survey.getUuid(surveyInfo)])

const fileMaxSize = isSystemAdmin ? fileMaxSizeSystemAdmin : fileMaxSizeDefault

return (
<div className="home-survey-create">
<div className="row">
Expand Down Expand Up @@ -201,7 +208,7 @@ const SurveyCreate = (props) => {
? { [contentTypes.zip]: ['.zip'] }
: { [contentTypes.zip]: ['.collect', '.collect-backup', '.collect-data'] }
}
maxSize={1000}
maxSize={fileMaxSize}
onDrop={onFilesDrop}
droppedFiles={file ? [file] : []}
/>
Expand Down
39 changes: 5 additions & 34 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2781,15 +2781,14 @@
proj4 "^2.11.0"
uuid "^9.0.1"

"@openforis/arena-server@^0.1.32":
version "0.1.32"
resolved "https://npm.pkg.github.com/download/@openforis/arena-server/0.1.32/58dc1a4ac098ea4f46a023db7f3a020e98db2221#58dc1a4ac098ea4f46a023db7f3a020e98db2221"
integrity sha512-y5q3gwrL5OhBkuA/82NRxIUbw0WZmlT07hiWyZQRPVrQE8edyNrvxaK74FNfpUmioS91miWu7FVoZ0Tu4SUqKQ==
"@openforis/arena-server@^0.1.33":
version "0.1.33"
resolved "https://npm.pkg.github.com/download/@openforis/arena-server/0.1.33/13448844363ff86a38229938088a738f8528d8fc#13448844363ff86a38229938088a738f8528d8fc"
integrity sha512-OUp5NyXSUBHzM14lWPkSDrH5O4s46krmB+4q+w8Y+NlzIDZ51Ivt6J/l+s8pSUBW0HqtjjwsSf0vK6wDLBy2cg==
dependencies:
"@godaddy/terminus" "^4.12.1"
"@openforis/arena-core" "^0.0.188"
bcryptjs "^2.4.3"
body-parser "^1.20.2"
compression "^1.7.4"
connect-pg-simple "^9.0.0"
db-migrate "^0.11.14"
Expand Down Expand Up @@ -4862,24 +4861,6 @@ body-parser@1.20.1:
type-is "~1.6.18"
unpipe "1.0.0"

body-parser@^1.20.2:
version "1.20.2"
resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.20.2.tgz#6feb0e21c4724d06de7ff38da36dad4f57a747fd"
integrity sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==
dependencies:
bytes "3.1.2"
content-type "~1.0.5"
debug "2.6.9"
depd "2.0.0"
destroy "1.2.0"
http-errors "2.0.0"
iconv-lite "0.4.24"
on-finished "2.4.1"
qs "6.11.0"
raw-body "2.5.2"
type-is "~1.6.18"
unpipe "1.0.0"

bonjour-service@^1.0.11:
version "1.1.1"
resolved "https://registry.yarnpkg.com/bonjour-service/-/bonjour-service-1.1.1.tgz#960948fa0e0153f5d26743ab15baf8e33752c135"
Expand Down Expand Up @@ -5569,7 +5550,7 @@ content-disposition@0.5.4:
dependencies:
safe-buffer "5.2.1"

content-type@~1.0.4, content-type@~1.0.5:
content-type@~1.0.4:
version "1.0.5"
resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.5.tgz#8b773162656d1d1086784c8f23a54ce6d73d7918"
integrity sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==
Expand Down Expand Up @@ -12204,16 +12185,6 @@ raw-body@2.5.1:
iconv-lite "0.4.24"
unpipe "1.0.0"

raw-body@2.5.2:
version "2.5.2"
resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.5.2.tgz#99febd83b90e08975087e8f1f9419a149366b68a"
integrity sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==
dependencies:
bytes "3.1.2"
http-errors "2.0.0"
iconv-lite "0.4.24"
unpipe "1.0.0"

rc@^1.2.8:
version "1.2.8"
resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed"
Expand Down

0 comments on commit 7de00be

Please sign in to comment.