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

Permalinks for folders and files that work across internal users when sharing #11732

Closed
PVince81 opened this issue Oct 23, 2014 · 46 comments · Fixed by #24434
Closed

Permalinks for folders and files that work across internal users when sharing #11732

PVince81 opened this issue Oct 23, 2014 · 46 comments · Fixed by #24434
Assignees
Milestone

Comments

@PVince81
Copy link
Contributor

The main use case is being able to easily copy/paste/share links to any shared folder/subfolder/files inside of ownCloud between users, independently from their location.

Current problems with internal folder links

Paths inside links are not consistent across users.

In OC 6

  1. User1 shares a folder "test folder" with User2
  2. User1 wants to send a link to a subfolder or file, for example: "test folder/subdir/coolfile.odt"
  3. User1 copies the browser URL "index.php/files?dir=test%20folder/subdir", then prepends "/Shared" since User2 will have it appear there, the link becomes "index.php/files?dir=Shared/test%20 folder/subdir"
  4. User1 sends an email with the link
  5. User2 opens the link, which shows the correct folder

Problem: for owner the path inside the link is "/test folder/subdir" but for any other user it's "/Shared/test folder/subdir".

In OC 7

Since OC 7 is is now possible for User2 to store "test folder" anywhere in their ownCloud, so the link "files?dir=Shared/test%20folder/subdir" will not work any more.

Problem: every user can potentially require a completely different path inside the links, and the target path is not predictable. It is not possible to paste a single link in a group email. You'd need to send an individual link to every one.

Extended use case

If User1 moved "subdir" to another location inside that share, the link will not be valid any more for neither User1 or User2.

Introducing permalinks

Concept

Currently, files and folders all have an internal file id which doesn't change most of the time (to be discussed).

The idea is to introduce a new format for link, with the form: "index.php/files?id=12345" where 12345 is the file id of the file or folder.

The workflow would be as follows:

  1. User1 shares a folder "test folder" with User2
  2. User1 wants a link pointing to "test folder/subdir" to send to User2
  3. User1 enters "test folder/subdir" and clicks an anchor icon, which copies the link "index.php/files?id=12345" that points to "subdir"
  4. User1 pastes the link in an email dialog with User2
  5. User2 opens the link
  6. System checks whether User2 has access to the file with id 12345 through any shares
  7. System resolves the file id to the path related to User2
  8. System redirects the browser to the matching path, for example "index.php/files?dir=allshareswithuser2/test%20folder/subdir".

If User1 moves "subdir" to another location inside of the "test folder" share, the folder will still be accessible with the link "index.php/files?id=12345".

For a file "coolfile.odt", the link would resolve to "index.php/files?dir=test%folder/subdir&scrollto=coolfile.odt" (for now, until we have direct links to files)

Possible extensions

The activity app, for example, could also make use of such permalinks to make sure

Potential problems

Link format not user readable

The link itself would not contain the file name/subdir any more but just the id, which is not user friendly as one cannot easily distinguish links. On the other hand: this is already how it's done for public links. Possible solution: add a dummy parameter in the link with the full path, but the parameter is ignored by the system.

Preserving the file id

We need to make sure that all file operations will preserve the file id.

  • As far as I know most basic operations should preserve the file id, which includes renaming, moving.
  • Not sure about upload+overwrite, moving between storages.
  • Moving between shared folders will most likely NOT preserve the file id, but that might be ok as the sharing information will change as well.
  • Deleting, then restoring files will NOT preserve the file id
  • ... more research required

I think this would be a nice improvement to solve the age-old question "how can I easily get a link to any folder inside ownCloud and share that link with other internal users ? (without having to fiddle with the URL...)"

@owncloud/designers @MTRichards @karlitschek @craigpg

@icewind1991 @schiesbn for file id questions

CC @LukasReschke

@PVince81
Copy link
Contributor Author

For the design part, the question is where can the user get access to the permalink.
There are multiple possibilities:

  1. Make the anchor tag of the file/folder point to the file id instead of the file name, this makes it copiable with right click + copy
  2. Add a new "Link to this" action in the file row (might be too flashy)
  3. Add an anchor link in the controls bar "permalink".
  4. Simply add the current folder id in the URL: "index.php/files?dir=currentdir&id=1234". When resolving the link it will first try with the id. If it doesn't exist, it will fall back to using "dir".

@jancborchardt
Copy link
Member

2 Add a new "Link to this" action in the file row (might be too flashy)

Not another action please. It will only confuse people about what it actually does.

3 Add an anchor link in the controls bar "permalink".

Nope, same as above.

Honestly copying the link/URL is fine in this case and is the thing which should be optimized.

@PVince81
Copy link
Contributor Author

Ok, then option 4. is probably the best.
Make the URL always include the file id to make it copiable.

@LukasReschke
Copy link
Member

Yes. That would make most sense!

Very cool proposal! - I see a lot of very good use-cases for that.

@PVince81
Copy link
Contributor Author

Note: would volunteer to implement this myself.

@PVince81 PVince81 self-assigned this Oct 31, 2014
@jbtbnl
Copy link
Contributor

jbtbnl commented Oct 31, 2014

What about the following use-case:

  1. User shares folder "/latest" with some people
  2. User develops a new version of the software in "/dev"
  3. User renames "/latest" to "/v1" and "/dev" to "/latest"

Now the user might assume that the link will still work, because the dummy variable shows the path to the latest version of the software. The link indeed still works, but now the people the link was originally shared with cannot reach the latest software.

A kind of a solution would be to only include the folder name (without the full path) in the link.

@PVince81
Copy link
Contributor Author

True, but there are use cases where even the target name might change.
We could also have only the file id in the URL, but then the links would be indistinguishable. (but I guess that's also how Google docs works, their pathes are only hashes, similar to OC's public links)

@PVince81
Copy link
Contributor Author

PVince81 commented Nov 4, 2014

Another problem that it solves is that activities are pointing to specific folders, so when scrolling back in time one won't be able to directly access to files that might have been moved. If the activity app could provide such permalinks, renamed/moved files would still be accessible.

@jbtbnl
Copy link
Contributor

jbtbnl commented Nov 5, 2014

There is definitely a use case for both, but which one should be the default? I'd say the permalink could be the default, with an option for absolute links.

Not sure if @jancborchardt will be happy with two linking options in the UI though 😄
But removing (new) absolute linking would be a regression for users that are already accustomed to it.

@jancborchardt
Copy link
Member

I would say the absolute linking with just a clear name is ok. If stuff is renamed, then it’s renamed.

@PVince81
Copy link
Contributor Author

Found a few situations where the file id isn't stable: #13310

@PVince81
Copy link
Contributor Author

@MTRichards

@MTRichards
Copy link
Contributor

This seems like a good polishing item. @karlitschek curious your thoughts?

@PVince81
Copy link
Contributor Author

Could be useful for the activity app to point to files even when they have been moved/renamed.

@PVince81
Copy link
Contributor Author

Could be make to work with the trashbin as well in some cases: #11732

@PVince81
Copy link
Contributor Author

PVince81 commented Jul 3, 2015

Note to self: file ids can be resolved to the current user's path using \OC\Files\Filesystem::getPath($fileId);. But then it would be nicer to have this on the public API, raised here: #17385

@PVince81
Copy link
Contributor Author

PVince81 commented Dec 2, 2015

@karlitschek suggested at some point to reuse public link shares / tokens and then when you open the public link, if you're logged in, show the folder in your actual view (if you have access). Might be worth exploring this approach too.

@PVince81
Copy link
Contributor Author

PVince81 commented May 4, 2016

Thanks for all the comments.

I think I'll go with the following:

  • introduce a new URL format containing the file id, for example "http://localhost/owncloud/index.php/f/123". This is like the "s" one for public shares but for files. "123" is the file id.
  • opening this URL will redirect the user to the files app
    • if the link points at a folder, the folder contents will be shown
    • if the link points at a file, the file list will scroll and highlight the file in question
  • the file's link will be available in the sidebar under an anchor-like icon, at the top-right (might need some tweaks to avoid confusion with the regular share link)
    • clicking that icon will provide a small dropdown/popup containing the short link as above (optional)
    • right-clicking it / copying link ("a" element) will also provide the same link

Additional thoughts:

  • instead of the file id, we could base64 encode the fileid to make the link look more "fancy"
  • maybe trigger the default action of a file after scrolling down to it. Discussed this with @nickvergessen and we decided against it because we cannot always guess the intention of the user/sharer (do they want to download/edit or view the file?). So best is to highlight it and let the user choose.

@MorrisJobke
Copy link
Contributor

the file's link will be available in the sidebar under an anchor-like icon, at the top-right (might need some tweaks to avoid confusion with the regular share link)

This feels really unintuitive - having two different URLs for the same stuff. I want to copy simply my address bar content and send it to someone (that is also how the sharing on mobile platforms from inside the browser work - they simply send the URL of the tab). cc @jancborchardt

@LukasReschke
Copy link
Member

Agreeing with @MorrisJobke. I think it may be useful to just have the folder ID in the URL as well? Or maybe even only the folder ID?

If somebody has an old link stored somewhere we would use the old logic, if somebody has a new link the new one :)

@PVince81
Copy link
Contributor Author

PVince81 commented May 4, 2016

Some reasons for why I like the separate URL (which is just a redirect):

The other part I like about the "http://localhost/owncloud/f/$fileId" is also that it opens up new possibilities:

  • when user has no access, display a page with a form to request access (could even obsolete public links)

I agree that it's not intuitive for people who are used to copy links.
Maybe we could have both ?

(note: I have the short link already implemented locally)

@PVince81
Copy link
Contributor Author

PVince81 commented May 4, 2016

Ah, and there's another problem with copying the URL from the browser: you cannot point directly at a file, only folders.

@guruz
Copy link
Contributor

guruz commented May 4, 2016

Why not do it like Amazon? all URLs are valid:

(Bad example maybe with the umlaut, but at least you get an idea what the link is for.. especially when there are multiple in an e-mail or so)

@PVince81
Copy link
Contributor Author

PVince81 commented May 4, 2016

For now I intend to support both, the code addition is minimal.
Just did it locally, will push later today 😄

@MorrisJobke
Copy link
Contributor

For now I intend to support both, the code addition is minimal.

Okay. This means, that it is not a redirect, but simply shows the content. 👍

@PVince81
Copy link
Contributor Author

PVince81 commented May 4, 2016

PR here (still WIP): #24434

I see additional tricky challenges with "fileid" in the regular URL:

  • non "All files" views like "Shared with me" handling
  • browser back button with history API: JS code needs to decide whether to use the fileid (might be obsolete ?) or "dir" argument
  • auto-adding "fileid" in the URL from the server without causing redirect loop: might rely on JS code to add it instead

@PVince81
Copy link
Contributor Author

PVince81 commented May 4, 2016

Okay. This means, that it is not a redirect, but simply shows the content

At the moment it is a redirect to the correct folder (in case the folder changed name or so).
Making it display the correct folder is much more complex: the JS code would need an API to resolve fileid to folder, and then do its PROPFIND and possibly also replace the URL with the correct one (which has almost the same result as a redirect)

@PVince81
Copy link
Contributor Author

PVince81 commented May 4, 2016

Hmm looks like keeping this extra "fileid" argument up to date in the URL requires deeper changes in the JS code:
There's a delay between "load this folder" and before we can know the file id. So we cannot change the URL directly and have to wait until loading is done. (in the past the URL was changed first in case loading fails the user can just reload the page). This is especially relevant because the fileid isn't always known. Here are some cases:
- initial page load on folder with unknown fileid: fileid becomes known after PROPFIND
- clicking on a folder to nav into it: fileid is known at click time (data-id)
- clicking on a breadcrumb: fileid not known until after PROPFIND

Trying to find a way around this and limit regression risks.

@PVince81
Copy link
Contributor Author

PVince81 commented May 4, 2016

Okay, I found a way: #24434 (comment)

Please try it out!

@PVince81 PVince81 mentioned this issue May 6, 2016
4 tasks
@PVince81
Copy link
Contributor Author

PVince81 commented May 6, 2016

Possible extensions:

@MorrisJobke MorrisJobke modified the milestones: 9.1-current, backlog May 10, 2016
@PVince81
Copy link
Contributor Author

@MTRichards @cmonteroluque @jospoortvliet @carlaschroder this feature was merged for 9.1 !

@jospoortvliet
Copy link

Congrats, this is very cool!

@MTRichards
Copy link
Contributor

Awesome!

@PVince81
Copy link
Contributor Author

A nice addition would be to make it possible to request access to a file one doesn't have access to: #25317

This could happen if someone shared the permalink by email to lots of people.

@lock
Copy link

lock bot commented Aug 4, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.