Fwrite() expects parameter 3 to be integer

Hi everyone!

I’ve set up Nextcloud on my Raspberry Pi 3 in order to stream my video content using WebDAV (among other things :slight_smile: ).
I’ve installed Kodi on a remote computer and defined a WebDAV connection to my Nextcloud.
Streaming works fine, but I’ve found a bunch of errors in the log (see below).

Nextcloud version:
Operating system and version: OSMC 2018.12-1 (Debian Stretch)
Apache version: 2.4.25
PHP version: 7.0

The issue you are facing:

PHP error shown below in Nextcloud log section.

Is this the first time you’ve seen this error?: Y

Steps to replicate it:

  1. Run library update in Kodi connected to Nextcloud via WebDAV protocol.

The output of your Nextcloud log in Admin > Logging:

[PHP] Error: fwrite() expects parameter 3 to be integer, string given at /var/www/nextcloud/3rdparty/sabre/http/lib/Sapi.php#88

HEAD /remote.php/dav/files/------rok.mkv
from ----- by ----- at 2019-03-30T23:53:27+00:00

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

The output of your Apache:
Apache log

I’ve looked at the code in Sapi.php and it seems that


is causing the issue by not returning an integer value.

I’ve also determined that all the errors in the log are connected to mkv files larger that 2 GB.
Smaller files are not causing this.

Anyone has any idea why is this happening?

Is this a 64-bit version of your OS? With 32-bit there are issues with php and files >2 GB. I didn’t follow up the plans for a work-around if it is already implemented…

OSMC on Raspberry Pi is 32 bit OS.

Are you saying this is PHP issue and there might be a workaround or Nextcloud issue?

Yes, there are php issues with 32-bit and large files. There is a thread on NextcloudPi, it is a raspbian-based image for RaspberryPi, so if they manage to get it work, you should as well:

Thanks for this, I’ve read through it.

This version of NC has this workaround already implemented.

I’ve did a test and uploaded an iso file of about 4 GB.
The upload was done piecemeal:

  • The file was broken down to many 8MB files and uploaded
  • Then the pieces were merged into the original iso file

At first all seemed fine as the iso file emerged in the list of files on the server, but when I checked the log I found this:

[PHP] Error: file_put_contents(): content truncated from 4071849984 to 2147483647 bytes at /var/www/nextcloud/lib/private/Files/Storage/Local.php#467

It looks like the file was truncated to 2GB although the upload_max_filesize and post_max_filesize are set to much higher value.