Server: Include server and userId into direct link

Created on 4 Feb 2020  ·  11Comments  ·  Source: nextcloud/server

Currently a direct link is: http://localhost/nc/index.php/f/1106
To have this more generic and that we can use it in https://github.com/nextcloud/android/pull/5345, idea is to switch it to:
{baseUrl}/index.php/f/{userId}/{fileId}

Ref: https://github.com/nextcloud/android/pull/5345#issuecomment-579936189

0. Needs triage enhancement

All 11 comments

@tobiasKaminsky I think the current direct link is: http://localhost/index.php/f/1106. (note the lack of nc).

In nextcloud/android#5345, the intent filter potentially catches other websites that may use .../index.php/f.... It would be preferable if the direct link contains something that is specific to nextcloud.

I would vote to let it as it is because including the userid in the internal link wouldn't work for external storages or groupfolders: you had to change manually the hardcoded userid for each user and cannot post just one link that works for all users that have access to the folder.

but that would be fine for me:

In nextcloud/android#5345, the intent filter potentially catches other websites that may use .../index.php/f.... It would be preferable if the direct link contains something that is specific to nextcloud.

@tobiasKaminsky wouldn't my proposed solution work for the android app:

Another solution would be trying the current active account in the app first and iterate over the other accounts if more are available and it didn't find any match for the currently active account.

Then you wouldn't have to change the internal link.

@tobiasKaminsky, @Charon77
Here an improvement to my idea:
What if you use the domain, in the case of http://localhost/index.php/f/1106 would that be localhost to identify all matching accounts that are signed in the app and iterate over those found accounts (the active one first)?
That should work in 99.99% of all cases.


please also look at my idea and the following discussion starting here and below: https://github.com/nextcloud/android/pull/5345#issuecomment-582066821

actually if there ever WAS a change, it probably makes more sense to have it as:

protocol://user@host/index.php/f/{fileId}

But yea. Remains to be seen if it can be solved via @szaimen suggestion instead of doing this.

protocol://user@host/index.php/f/{fileId}

Two things to address here: user@host part, and the protocol

For the user@host:

I think what @szaimen means is that the user part should be optional, therefore, if the file is accessible by multiple user, other user (non-creator) can also use the link.

I suppose it's possible to perform checks as follow in these order:

  1. See if we have user@host acount and try to open it

  2. Try our active (current) account

  3. Try all of our accounts that matches the host

As for the protocol, if the direct link is opened by say, android phones, then no problem here. But what if user opens the direct link from PC? Can the browser handle something like nc:// ? Will direct link only work if the user have the app installed? Right now users can click on the direct link and have it opened in the browser, so I think users still needs to open such link in browser if they don't have the app.

As for the protocol, if the direct link is opened by say, android phones, then no problem here. But what if user opens the direct link from PC? Can the browser handle something like nc:// ? Will direct link only work if the user have the app installed? Right now users can click on the direct link and have it opened in the browser, so I think users still needs to open such link in browser if they don't have the app.

http and https are also protocols ;)

I think what @szaimen means is that the user part should be optional, therefore, if the file is accessible by multiple user, other user (non-creator) can also use the link.

Yes 👍

And the link is shorter and looks better if it doesn't include the username.

And you don't have to change the internal link what can take a long time...

True, adding userId to the link will not work for other users…
Have not thought about that :/

please also look at my idea and the following discussion starting here and below: nextcloud/android#5345 (comment)

Indeed, I guess that is the best way…

this is something that could get addressed by this issue:

In nextcloud/android#5345, the intent filter potentially catches other websites that may use .../index.php/f.... It would be preferable if the direct link contains something that is specific to nextcloud.

Because it doesn't contain user-specifig things. But maybe only for a later release...

@szaimen improved links handling on Android: https://github.com/nextcloud/android/pull/6121
Is there anything to do on the server side, such as documentation update?

Was this page helpful?
0 / 5 - 0 ratings