server icon indicating copy to clipboard operation
server copied to clipboard

Syncing: Automatically create folder structure when uploading files

Open sorbaugh opened this issue 6 months ago • 4 comments

In order to improve synchronization between Files Client and Server, it would be helpful to automatically create the folder structure when uploading files.

Example: when doing an upload to /foo/bar/example.txt, automatically create /foo and /foo/bar

sorbaugh avatar Jun 10 '25 15:06 sorbaugh

+1 here.

I can observe a lot of uploads resulting in 404 because the folder structure (very frequently, the last folder) doesn't exist, resulting in a never-end loop of trying to upload files that never succeeds.

PUT /remote.php/dav/files/user/InstantUpload/Camera/20250302_171042.jpg 404

solracsf avatar Jun 10 '25 20:06 solracsf

I can observe a lot of uploads resulting in 404 because the folder structure (very frequently, the last folder) doesn't exist, resulting in a never-end loop of trying to upload files that never succeeds.

Where? This is a client (also counting the webui as one) issue.

susnux avatar Jun 16 '25 13:06 susnux

Problem with this is, if we implement this we will break with the WebDAV standard as its required for the folder to exist before doing the upload (PUT) otherwise the server MUST respond with a 409 error.

So its up to the client to do the MKCOL before uploading.

See also the WebDAV RFC: https://datatracker.ietf.org/doc/html/rfc4918#section-9.7.1

susnux avatar Jun 16 '25 13:06 susnux

It seems like even MKCOL calls need to have existing ancestor collections and must fail if not.

So basically there is no way to implement this without breaking the standard.

salmart-dev avatar Jun 16 '25 13:06 salmart-dev

Where? This is a client (also counting the webui as one) issue.

I can observe this from Android clients as per requests User-Agent.

solracsf avatar Jun 16 '25 16:06 solracsf

The proposed PR solves the standard-adherence question nicely by making this opt-in via custom header. Nice.

sorbaugh avatar Jun 25 '25 14:06 sorbaugh

Is this feature going to be implemented as should in the future? The inconvenience of having to create the folders myself for auto-uploading photos is horrid.

BerryRoelfsema avatar Jul 25 '25 12:07 BerryRoelfsema

As you can see this is already implemented in https://github.com/nextcloud/server/pull/53621 for Nextcloud 32 WebDAV compatible clients nevertheless should already handle this correctly as per standard.

susnux avatar Jul 25 '25 15:07 susnux