Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload to Nextcloud 21 does not work #6

Closed
ntimo opened this issue Mar 21, 2021 · 6 comments
Closed

Upload to Nextcloud 21 does not work #6

ntimo opened this issue Mar 21, 2021 · 6 comments

Comments

@ntimo
Copy link

ntimo commented Mar 21, 2021

I am currently trying to upload files to a drop link to Nextcloud version 21.

I am using this example command to upload:
./cloudsend.sh './myfile.txt' 'https://cloud.mydomain.net/s/fLDzToZF4MLvG28'

The upload is done from a alpine 3.13 image with follwing installed:
apk add python3 bash build-base gcc jq coreutils curl

But I am getting this error:


stty: 'standard input': Not a tty
attachments-to-nextcloud    | <html><body><h1>400 Bad request</h1>
attachments-to-nextcloud    | Your browser sent an invalid request.
attachments-to-nextcloud    | </body></html>
attachments-to-nextcloud    | 
attachments-to-nextcloud    | 
attachments-to-nextcloud    |  > Curl exited without errors

Do you have a clue why?

@tavinus
Copy link
Owner

tavinus commented Mar 25, 2021

Would be nice to see the actual call you made to get this error ( just change the url to [URL]).

In cloudsend.sh, try changing the hashbang (first line) from

#!/usr/bin/env bash

To your alpine bash location (eg.)

#!/bin/bash

You can find it with

which bash

or

command -v bash

Then also try to run from Bash (instead of Busybox/Ash).
Just call bash. Then run from it.

Since I don't have much info, I am just guessing some stuff.
I would guess this is more of an Alpine problem than NC21.
Or you just made an invalid call.

Cheers
Tav

@teriansilva
Copy link

Just something I noticed, NC21 changed the webdav routes. They are not remote.php/webdav/... but remote.php/dav/files/[username]

@tavinus
Copy link
Owner

tavinus commented May 1, 2021

This is a bit confusing.

From the documentation, they seem to use

  • /dav/ for remote.php
  • /webdav/ for public.php

The Apache / Nginx / Other proxy configuration can also cause problems. The proxy config could also solve the problem by redirecting/rewriting /dav/ to /webdav/ or vice-versa.

The NC21 documentation still lists the correct folder as

https://example.com/nextcloud/public.php/webdav

They may have changed the code and not updated the docs though. I don't have a NC21 to test at this point.

One issue is that if the wrong one is used, there is no error. No error from curl and no response error as well.

If I try to open the correct one without the token/password, I would get a XML with an error as response. The wrong one returns nothing. So, I guess I could try one, see if I get the error response and then try the other one if I get nothing. This would require an extra curl call, some parsing, etc.

Example response

$ curl 'https://cloud.mydomain.tld/public.php/webdav/'
<?xml version="1.0" encoding="utf-8"?>
<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
  <s:exception>Sabre\DAV\Exception\NotAuthenticated</s:exception>
  <s:message>No 'Authorization: Basic' header found. Either the client didn't send one, or the server is misconfigured</s:message>
</d:error>

Example blank

$ curl 'https://cloud.mydomain.tld/public.php/dav/'

But then I noticed that the one that does not work actually returns a '404 Not Found' status and the one that works returns a '401 Unauthorized' status code.

I still dislike the overhead of an extra curl call, but I can't see other way of automagically checking this. Only other option is to have a parameter that would change it or turn checking on.

I will probably try it without authentication and check for the 401 status code (the one that works). Then if it gets anything else, change webdav to dav and check again. If failed again, exit program.

I like the idea of at least having a way to make multiple calls not check every time.

@teriansilva I will let you know when I implement this so you can test in NC21.

Cheers!

@tavinus
Copy link
Owner

tavinus commented May 1, 2021

Example calls to get URL status

401

$ curl -s -o /dev/null -I -w "%{http_code}" 'https://cloud.mydomain.tld/public.php/webdav/'
401

404

$ curl -s -o /dev/null -I -w "%{http_code}" 'https://cloud.mydomain.tld/public.php/dav/'
404

@tavinus
Copy link
Owner

tavinus commented May 1, 2021

I will wait for some confirmation that the public.php URL actually changed from /webdav/ to /dav/ in NC21.

The remote.php URL has been changed to /dav/ for quite some time already, but that is another thing.

@tavinus
Copy link
Owner

tavinus commented Oct 8, 2021

I never got to try this in NC21. But I tested it in NC20 and NC22 and they both worked without problems. Since the original poster never bothered to reply with more info and this problem was never confirmed, I will close this.

@tavinus tavinus closed this as completed Oct 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants