Is there a way to write file on disk without temp file?

Hi to all and sorry for my English.

My question
Is there any way to configure\modify my NextCloud to write data on the disk\NAS without using php-temp file?

Details
RaspberryPi v4
Nextcloud version: 20.0.5
Operating system and version: Linux 5.4.0-1015-raspi aarch64
Apache or nginx version: Apache/2.4.41 (Ubuntu)
PHP version: PHP 7.4.3 (cli) (built: Oct 6 2020 15:47:56) ( NTS )
My files are stored at NAS and i’m the only user of my private cloud.

I’d like to improve the speed of writing files while using WebDav.
I’ve made some tests.
Writing 1,45 Gb file straight on my NAS takes 67 seconds
Writing the same file on NAS through WebDav-NextCloud-Raspberry takes 2 min 52 sec (172 sec).
I’ve tried to understand, why there is such a big difference.

Using

strace -yy -e trace=open,openat,close,write,read -f -p `bash -c 'pgrep apache | tr "\n" ","'` 2>&1

I’ve found out that:

  • when client sends a file → the file is written to the memory
    (and this is why the sending process is so fast until it reaches 99%)
  • loop:
    – a chunk \ part of the file from the memory is written on php_tmp file
    (that is the path, which specified in the sys_temp_dir setting in php.ini)
    – the chunk of the file from the php_tmp file is written on NAS
    – repeating

Sample of the log:

[pid 2853] read(13<TCPv6:[[0000::0000:0000:0000:0000]:443->[0000::0000:0000:0000:1111]:60669]>, "\316\255\///"..., 8000) = 8000
[pid 2853] write(17</tmp/phpbAVJjX>, "\265\256F\320\33..."..., 8192) = 8192
[pid 2853] read(17</tmp/phpbAVJjX>, "\265\256F..."..., 8192) = 8192
[pid 2853] write(16</mnt/%DATA_FOLDER%/%USER_NAME%/files/%FILE_NAME%>, "\265\256F\320\335\34wb\..."..., 8192) = 8192

[pid 2853] read(13<TCPv6:[[0000::0000:0000:0000:0000]:443->[0000::0000:0000:0000:1111]:60669]>, "He\307\374\305NWF-\371\367\32...1|"..., 8000) = 8000
[pid 2853] write(17</tmp/phpbAVJjX>, "*\37\17~=\255C\273d\...]"..., 8192) = 8192
[pid 2853] read(17</tmp/phpbAVJjX>, "*\37\17~=\255C\273d\2...]"..., 8192) = 8192
[pid 2853] write(16</mnt/%DATA_FOLDER%/%USERNAME%/files/%FILE_NAME%>, "*\37\17~=\255C\273d\204\..."..., 8192) = 8192

Is there a way to write chunks\parts of file being uploaded right on the NAS, without using php_tmp file?
I think this way may improve uploading speed.