Content
View differences
Updated by Artur Neumann over 3 years ago
**As** a user
**I want to** receive help when an upload of a file to Nextcloud was rejected if the file is too big
**so that** I know how to circumvent the problem, by manually uploading the file to Nextcloud (using its chunked upload) and linking it to the work package afterwards.
**Acceptance criteria**
* When I update a file that is larger than what the post can handle but that is still valid in terms of maximum file size and quota then I should receive a meaningful error message: "The selected file is too big for uploading it here in OpenProject. For files that big we recommend uploading them directly in Nextcloud first. Then you can link them to this work package."
## Additional information on how to fail on upload
### Nextcloud quota
* create a user
* set quota in the user administration
### file access control
* install file access control app
* create a limiting flow in "Administration -> Flow"
### files antivirus
* install and configure the file-antivirus app and background antivirus software
* upload "eicar" virus file [https://www.eicar.org/download-anti-malware-testfile/](https://www.eicar.org/download-anti-malware-testfile/)
### POST size & upload size
#### set both settings to the same value
set `PHP_UPLOAD_LIMIT` env variable of the nextcloud service container in the `docker-compose.override.yml` to the integer value of the maximum bytes to be uploaded
This will cause the PHP settings `upload_max_filesize` and `post_max_size` in `/usr/local/etc/php/conf.d/nextcloud.ini` to be set to the value of `PHP_UPLOAD_LIMIT`
The issue with that is, that it will cause always run in the POST size limitation, because we are sending the data as multipart/form-data (base64 encoded makes post\_size > file\_size; baase64 has an overhead of 33–37% plus we can send extra data like the overwrite switch)
#### set values independently
For productive environments it's good practice to have post\_max\_size set to a bigger value than upload\_max\_filesize.
1. _upload\_max\_filesize (set to 1023 bytes)_
`docker compose exec nextcloud sed -i 's/upload_max_filesize=.*$/upload_max_filesize=1023/' /usr/local/etc/php/conf.d/nextcloud.ini`
`docker compose exec nextcloud service apache2 restart`
reverse to default settings with:
`docker compose exec nextcloud sed -i 's/upload_max_filesize=.*$/upload_max_filesize=\${PHP_UPLOAD_LIMIT}/' /usr/local/etc/php/conf.d/nextcloud.ini`
`docker compose exec nextcloud service apache2 restart`
2. _post\_max\_size (set to 1023 bytes)_
`docker compose exec nextcloud sed -i 's/post_max_size=.*$/post_max_size=1023/' /usr/local/etc/php/conf.d/nextcloud.ini`
`docker compose exec nextcloud service apache2 restart`
reverse to default settings with:
`docker compose exec nextcloud sed -i 's/post_max_size=.*$/post_max_size=\${PHP_UPLOAD_LIMIT}/' /usr/local/etc/php/conf.d/nextcloud.ini`
`docker compose exec nextcloud service apache2 restart`
**I want to** receive help when an upload of a file to Nextcloud was rejected if the file is too big
**so that** I know how to circumvent the problem, by manually uploading the file to Nextcloud (using its chunked upload) and linking it to the work package afterwards.
**Acceptance criteria**
* When I update a file that is larger than what the post can handle but that is still valid in terms of maximum file size and quota then I should receive a meaningful error message: "The selected file is too big for uploading it here in OpenProject. For files that big we recommend uploading them directly in Nextcloud first. Then you can link them to this work package."
## Additional information on how to fail on upload
### Nextcloud quota
* create a user
* set quota in the user administration
### file access control
* install file access control app
* create a limiting flow in "Administration -> Flow"
### files antivirus
* install and configure the file-antivirus app and background antivirus software
* upload "eicar" virus file [https://www.eicar.org/download-anti-malware-testfile/](https://www.eicar.org/download-anti-malware-testfile/)
### POST size & upload size
#### set both settings to the same value
set `PHP_UPLOAD_LIMIT` env variable of the nextcloud service container in the `docker-compose.override.yml` to the integer value of the maximum bytes to be uploaded
This will cause the PHP settings `upload_max_filesize` and `post_max_size` in `/usr/local/etc/php/conf.d/nextcloud.ini` to be set to the value of `PHP_UPLOAD_LIMIT`
The issue with that is, that it will cause always run in the POST size limitation, because we are sending the data as multipart/form-data (base64 encoded makes post\_size > file\_size; baase64 has an overhead of 33–37% plus we can send extra data like the overwrite switch)
#### set values independently
For productive environments it's good practice to have post\_max\_size set to a bigger value than upload\_max\_filesize.
1. _upload\_max\_filesize (set to 1023 bytes)_
`docker compose exec nextcloud sed -i 's/upload_max_filesize=.*$/upload_max_filesize=1023/' /usr/local/etc/php/conf.d/nextcloud.ini`
`docker compose exec nextcloud service apache2 restart`
reverse to default settings with:
`docker compose exec nextcloud sed -i 's/upload_max_filesize=.*$/upload_max_filesize=\${PHP_UPLOAD_LIMIT}/' /usr/local/etc/php/conf.d/nextcloud.ini`
`docker compose exec nextcloud service apache2 restart`
2. _post\_max\_size (set to 1023 bytes)_
`docker compose exec nextcloud sed -i 's/post_max_size=.*$/post_max_size=1023/' /usr/local/etc/php/conf.d/nextcloud.ini`
`docker compose exec nextcloud service apache2 restart`
reverse to default settings with:
`docker compose exec nextcloud sed -i 's/post_max_size=.*$/post_max_size=\${PHP_UPLOAD_LIMIT}/' /usr/local/etc/php/conf.d/nextcloud.ini`
`docker compose exec nextcloud service apache2 restart`