Curl Upload -> no overwrite possible

Nextcloud version (eg, 12.0.2): 18
Operating system and version (eg, Ubuntu 17.04): Centos
Apache or nginx version (eg, Apache 2.4.25): Nginx 1.16.1
PHP version (eg, 7.1): 72

The issue you are facing:
I upload files via

curl -T <myfile> -u "<share>:<password>" -H 'X-Requested-With: XMLHttpRequest' -X PUT https://<nextcloud-url>/public.php/webdav/
OR 
curl -T <myfile> -u "<share>:<password>" -H 'X-Requested-With: XMLHttpRequest' -H 'X-Method-Override: PUT' https://<nextcloud-url>/public.php/webdav/

The file got created in the share. Now i change the file and upload it again (same name). And the file will not overwritten. It will create a secound file called <myfile> (1).ext

Based on https://help.nextcloud.com/t/uploading-to-a-public-link-via-a-script/20294/13

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. Create Public upload share with password
  2. execute command
  3. change file
  4. execute command again

The output of your Nextcloud log in Admin > Logging:

[no app in context] Info: Deprecated event type for {"[object] (OCP\SabrePluginEvent)":{"*statusCode":200,"*message":"","*server":{"[object] (OCA\DAV\Connector\Sabre\Server)":{"tree":"[object] (OCA\DAV\Connector\Sabre\ObjectTree)","*baseUri":"/public.php/webdav/","httpResponse":"[object] (Sabre\HTTP\Response)","httpRequest":"[object] (Sabre\HTTP\Request)","sapi":"[object] (Sabre\HTTP\Sapi)","*plugins":[],"transactionType":null,"protectedProperties":{"...":"Over 20 items, aborting normalization"},"debugExceptions":false,"resourceTypeMapping":[],"enablePropfindDepthInfinity":true,"xml":"[object] (Sabre\DAV\Xml\Service)","*listeners":{"...":"Over 20 items, aborting normalization"},"*logger":null}},"Symfony\Contracts\EventDispatcher\EventpropagationStopped":false}}: null

PUT /public.php/webdav/<myfile>
from 172.16.1.2 at 2020-02-02T17:09:28+00:00

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

$CONFIG = array (
  'default_language' => 'de',
  'default_locale' => 'de_DE',
  'dbtype' => 'mysql',
  'version' => '18.0.0.10',
  'mysql.utf8mb4' => true,
  'installed' => true,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'maintenance' => false,
  'theme' => '',
  'app.mail.transport' => 'php-mail',
  'trashbin_retention_obligation' => 'auto,30',
  'versions_retention_obligation' => 'auto',
  'loglevel' => 1,
  'debug' => false,
  'logfile' => 'nextcloud.log',
  'log_type' => 'file',
);

The output of your Apache/nginx/system log in /var/log/____:

172.16.1.2 - oiMZ44tD5P9YGwZ [02/Feb/2020:18:13:21 +0100] "PUT /public.php/webdav/<myfile> HTTP/2.0" 201 0 "-" "curl/7.66.0" "-"

Nextcloud-Version: Nextcloud 18.0.6
I investigated the same problem. I use curl to upload backups and want to override the backups weekly. Because I only what to upload, the permissions for the public link are set to “upload only”. I investigated that when I set the permissions to “read and write” the override header

‘X-Method-Override: PUT’

is working. With “upload only” permission, new filenames are generated (2).

Is it possible to change this behavior? Maybe with a additional header “X-Method-Force-Override”?

Thanks,
Tobias