android icon indicating copy to clipboard operation
android copied to clipboard

Auto-Upload - conflict for not-existing files on server side (and upload does not work)

Open habakuk007 opened this issue 3 years ago • 16 comments

The Auto-Upload worked fine - then I upgraded to Nextcloud Server 23 (from 22 or 21) and also upgraded the Android app.

Since then the app tells me, that every new file is already on the server and does not upload any file.

End of original .htaccess:

ErrorDocument 403 //
ErrorDocument 404 //

I tried to adjust the .htaccess file and removed the redirection to the 404 document (I did not touch this file before!).

ErrorDocument 403 //
# ErrorDocument 404 //

Now the upload seams to work again.

Expected behaviour

  • It should upload my images like it did before - without manual hacks

Actual behaviour

  • It does not upload any file or picture (without manual hack)

Can you reproduce this problem on https://try.nextcloud.com?

  • Did not try yet.

Environment data

Android version: 12 Device model: Samsung Galaxy e10 Stock or customized system: Stock Nextcloud app version: 3.20.2 (F-Droid) Nextcloud server version: 23.0.6

Logs

Web server error log with active ErrorDocument 404 //

cloud.example.com:443 95.115.0.0 - m [21/Jun/2022:15:16:17 +0200] "HEAD /remote.php/dav/files/m//SofortUpload/Camera/2022/06/20220616_140902.jpg HTTP/1.1" 302 0 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.18.1"
cloud.example.com:443 95.115.0.0 - m [21/Jun/2022:15:16:17 +0200] "HEAD /index.php/apps/dashboard/ HTTP/1.1" 200 0 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.18.1"

Web server error log without active # ErrorDocument 404 //

cloud.example.com:443 2a01:c22:: - s [21/Jun/2022:15:21:06 +0200] "HEAD /remote.php/dav/files/s//SofortUpload/Camera/2022/06/20220619_175846.jpg HTTP/1.1" 404 0 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.20.2"
cloud.example.com:443 2a01:c22:: - s [21/Jun/2022:15:21:06 +0200] "MKCOL /remote.php/dav/uploads/s/44a7dc43ebef710be21e0a8dcdf20525 HTTP/1.1" 201 0 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.20.2"
cloud.example.com:443 2a01:c22:: - s [21/Jun/2022:15:21:06 +0200] "PROPFIND /remote.php/dav/uploads/s/44a7dc43ebef710be21e0a8dcdf20525 HTTP/1.1" 207 786 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.20.2"
cloud.example.com:443 2a01:c22:: - s [21/Jun/2022:15:21:07 +0200] "GET /index.php/apps/files/api/v1/thumbnail/256/256/SofortUpload/Camera/2022/06/20220619_160719.jpg HTTP/1.1" 200 40630 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.20.2"
cloud.example.com:443 2a01:c22:: - s [21/Jun/2022:15:21:13 +0200] "PUT /remote.php/dav/uploads/s/44a7dc43ebef710be21e0a8dcdf20525/0000000000000000-0000000007117398 HTTP/1.1" 201 0 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.20.2"
cloud.example.com:443 2a01:c22:: - s [21/Jun/2022:15:21:13 +0200] "MOVE /remote.php/dav/uploads/s/44a7dc43ebef710be21e0a8dcdf20525/.file HTTP/1.1" 201 0 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.20.2"
cloud.example.com:443 2a01:c22:: - s [21/Jun/2022:15:21:14 +0200] "PROPFIND /remote.php/dav/files/s//SofortUpload/Camera/2022/06/20220619_175846.jpg HTTP/1.1" 207 1150 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.20.2"
cloud.example.com:443 2a01:c22:: - - [21/Jun/2022:15:21:15 +0200] "GET /index.php/204 HTTP/2.0" 204 0 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.20.2"

habakuk007 avatar Jun 21 '22 13:06 habakuk007

Seems that I am also affected: https://github.com/nextcloud/android/issues/7905#issuecomment-1164782151 ..

Knusper avatar Jun 23 '22 19:06 Knusper

I can confirm that this workaround works.

Knusper avatar Jun 26 '22 17:06 Knusper

Do you really have this double slash here? Does it work also if you change it to ErrorDocument 404 /

szaimen avatar Jun 27 '22 11:06 szaimen

I just checked the .httacces that ships with nextcloud Server https://github.com/nextcloud/server/blob/master/.htaccess

It does not contain these lines. Does it append stuff from a previous incarnation of this file during installation? If so, this must have been the default settings my hoster put there?

(Edit: Reading the changelogs from my hoster, I even find a mention that the Error Document feature is now available to users - so maybe they made a mistake in the default settings?)

Knusper avatar Jun 27 '22 13:06 Knusper

Reading the changelogs from my hoster, I even find a mention that the Error Document feature is now available to users - so maybe they made a mistake in the default settings?

Yeah, that may be possible...

szaimen avatar Jun 27 '22 17:06 szaimen

I just checked the .httacces that ships with nextcloud Server https://github.com/nextcloud/server/blob/master/.htaccess

It does not contain these lines.

Hi @Knusper,

I have not added those lines and I'm sure my hoster hasn't not either.

But I found this: https://github.com/nextcloud/server/blob/7acb438e428e5b0b3a79c2b7ce5a4283b0e805eb/lib/private/Setup.php#L490

It looks like Setup.php adds these lines to the .htaccess.

Regards! Stefan

habakuk007 avatar Jun 27 '22 21:06 habakuk007

Yeah but does it work with a single slash for you?

szaimen avatar Jun 27 '22 21:06 szaimen

Hi @szaimen, there is no difference between ErrorDocument 404 // and ErrorDocument 404 /

habakuk007 avatar Jun 29 '22 10:06 habakuk007

I also noticed that, if I make an update of the Nextcloud Server the ErrorDocument 404 // line is added again to my .htaccess file.

habakuk007 avatar Jun 29 '22 13:06 habakuk007

Yes, I can confirm. But now I don't get file conflict warnings anymore, the upload of new files just fails with connection error.

Knusper avatar Jul 15 '22 14:07 Knusper

I can confirm having the same problem.

Tested by installing a the newest stable server version 24.0.3 via the web installer, installing to the "." directory, using the default SQLite DB and not installing the recommended apps. The .htaccess file got the line ErrorDocument 404 // added.

When trying to upload a file (not even using the auto-upload), this is shown in the webserver access logs:

[24/Jul/2022:15:03:12 +0200] "HEAD /remote.php/dav/files/admin//IMG_20220123_113042.jpg HTTP/1.1" 302 0 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.20.3"
[24/Jul/2022:15:03:13 +0200] "HEAD /index.php/apps/dashboard/ HTTP/1.1" 200 0 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.20.3"

When removing that ErrorDocument line as OP mentioned, it works:

[24/Jul/2022:15:08:53 +0200] "HEAD /remote.php/dav/files/admin//IMG_20220123_113042.jpg HTTP/1.1" 404 0 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.20.3"
[24/Jul/2022:15:08:54 +0200] "PUT /remote.php/dav/files/admin//IMG_20220123_113042.jpg HTTP/1.1" 201 0 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.20.3"
[24/Jul/2022:15:08:54 +0200] "PROPFIND /remote.php/dav/files/admin//IMG_20220123_113042.jpg HTTP/1.1" 207 1173 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.20.3"
[24/Jul/2022:15:08:55 +0200] "GET /index.php/apps/files/api/v1/thumbnail/256/256/IMG_20220123_113042.jpg HTTP/1.1" 200 27404 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.20.3"

I tried it with an account on https://try.nextcloud.com/ a well. Interestingly it did work there. They are using version 24.0.0 though, but I have also tried specifically with that version and it failed for me. But since that line in .htaccess might not always be added, this is not a good comparison without knowing what exactly they have in that file.

rndph avatar Jul 24 '22 13:07 rndph

cc @kesselb what do you think about removing the errordocument part in the updatehtaccess function?

szaimen avatar Jul 24 '22 13:07 szaimen

Looks related to https://github.com/nextcloud/server/issues/33048

Sorry I don't know why we write ErrorDocument to .htaccess and if we still need it :man_shrugging:

kesselb avatar Jul 24 '22 15:07 kesselb

Ah, thanks for pointing this out. My hoster configure the server as described there, and that's why I get this nasty error. Currently the only solution for me is manually editing the .htaccess file after each update.

Knusper avatar Aug 13 '22 00:08 Knusper

I can confirm this error and couldn't share i.e. photos from an Android client as in this bug report https://github.com/nextcloud/android/issues/10628. "Solved" via editing the .htaccess file.

RhizomaticNomad avatar Aug 29 '22 13:08 RhizomaticNomad

Thank you! I couldn't upload files from my phones for months, with your fix it is working again, thanks!

d-sko avatar Sep 16 '22 21:09 d-sko

Anything we can do to fix this except edit the HTaccess file? I have a managed Nextcloud instance, so I cannot edit the HTaccess file.

TeaDrinkingProgrammer avatar Mar 06 '23 10:03 TeaDrinkingProgrammer

I think this should be solved automatically with nc26...

szaimen avatar Mar 06 '23 10:03 szaimen

Well, I have been trying to auto-upload my pictures to an empty InstantUpload folder and I get tons of conflicts and failed uploads, despite having tried 3 times.

TeaDrinkingProgrammer avatar Mar 06 '23 10:03 TeaDrinkingProgrammer

Well, I don't think you are running NC26 yet...

szaimen avatar Mar 06 '23 10:03 szaimen

My NC version is indeed 25, sorry for that.

TeaDrinkingProgrammer avatar Mar 06 '23 11:03 TeaDrinkingProgrammer

Looks related to nextcloud/server#33048

Sorry I don't know why we write ErrorDocument to .htaccess and if we still need it 🤷‍♂️

Thanks @kesselb : It looks like ProxyErrorOverride On could be indeed the cause of this problem for me.

pokulo avatar Nov 06 '23 19:11 pokulo

This was a Server matter: nextcloud/server#33048 and has been addressed in all supported version of NC Server at this point.

joshtrichards avatar Dec 07 '23 14:12 joshtrichards