-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Remote file paths #4537
Remote file paths #4537
Conversation
to avoid confusion with "folders"
Thanks for catching up with this, @mifi! I have played around with it and was a bit surprised by the I would argue we could make "your"
IMHO it would be nice to have the absolute path available as well, but the (c.f. #4486 (comment)) |
Thanks for your feedback.
IMO because the relativePath also includes the file's name, e.g.
I don't think relative path should have a leading
I think I will change the code for local files so it also removes the leading slash. The reasoning is that the current behaviour is inconsistent (sometimes leading slash, sometimes none, depending on browser): The fallback for relativePath for local files is
this could lead to bugs in implementations, if the developer always thinks that there is a leading slash when in fact there isn't always one.
I agree. will implement this. |
also: - implement absolutePath - always remove leading slash from local files (not only for webkitRelativePath)
You're welcome, I'm happy if we come to a solution, we are all happy with :)
Not sure, I would prioritize making In the end it's not too important for us, as we can probably workaround it rather easily, but easing implementations seems like a rather weak argument to introduce inconsistency here IMHO, as it's required to handle this for local files anyways.
Consistency is good, if you think it's worth introducing this in this PR - we will deal with it ;-)
Thanks, this was our most important concern. Latest commit works like a charm for me! |
This comment was marked as outdated.
This comment was marked as outdated.
Having tested this, I must say I was about to write the same points as @dschmidt did in the beginning. Here we have nesting in Played with
But when I select a single file on that demo page,
Also it does indeed sound like |
If we want to change the behaviour so that when selecting a file that is not in a folder,
Yes, this is what I mean. If relativePath is never null, then the developer using it can simply always just treat is as a valid path and construct their resulting directory structure directly from it, without needing to add a special check for
How do you select a single file on that demo page? did you remove the |
linking #3083 here as well |
But it will confuse people because it breaks with standard semantics known from browsers (and Uppy until now, it would be a breaking change and require e.g. us to adapt our code).
Yes, having a
to reliably concat paths, but for checking if a file is from a folder we need
From my pov it's making two things consistent that are not the same. |
We've decided to keep |
Okay, that is good news! What does unify file paths exactly mean? |
Yes, remove leading slashes. The filenames should stay as is, yes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly LGTM, couple comments
@@ -99,32 +129,34 @@ export default class ProviderView extends View { | |||
} | |||
|
|||
/** | |||
* Based on folder ID, fetch a new folder and update it to state | |||
* Select a folder based on its id: fetches the folder and then updates state with its contents | |||
* TODO rename to something better like selectFolder or navigateToFolder (breaking change?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need this todo? Name is not that bad.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getX
sounds to me like pure function (no side effects) that simply returns something. but this function does a whole lot more than that: it changes the breadcrumbs, it lists folders/files and then updates the state
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, almost everything in Uppy is state and almost all functions perform things on state. But yes since it's a public function I don't think we can change it now.
packages/@uppy/provider-views/src/ProviderView/ProviderView.jsx
Outdated
Show resolved
Hide resolved
...newItem, | ||
// calculate the file's path relative to the user's selected item's path | ||
// see https://github.com/transloadit/uppy/pull/4537#issuecomment-1614236655 | ||
relDirPath: newItem.absDirPath.replace(selectedItem.absDirPath, '').replace(/^\//, ''), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since you added absDirPath
yourself, can't we handle this in addPath
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure how that would work
@@ -92,6 +92,11 @@ export default class View { | |||
if (file.author.url) tagFile.meta.authorUrl = file.author.url | |||
} | |||
|
|||
// add relativePath similar to non-remote files: https://github.com/transloadit/uppy/pull/4486#issuecomment-1579203717 | |||
if (file.relDirPath != null) tagFile.meta.relativePath = file.relDirPath ? `${file.relDirPath}/${tagFile.name}` : tagFile.name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we currently change paths in three places: in addPath
, mutation in recursivelyListAllFiles
, and here. Would it be possible to have it centralised?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be possible to set the paths in recursivelyListAllFiles
- c.f. owncloud@9f111c5
I'm not handling absolute paths, but in @mifi 's implementation the absPath
is available in recursivelyListAllFiles
too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to set paths in multiple places, because not all files are loaded by recursivelyListAllFiles
# Conflicts: # packages/@uppy/provider-views/src/ProviderView/ProviderView.jsx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally and it works well 👍
One Q, the difference between absolute and relative path is not clear to me in the value in provides. The only difference here is a leading slash. When are these two different and why would you want to use the absolute path?
{
absolutePath: "/Two/9BSaOek-cowboy-bebop-backgrounds.jpg"
relativePath: "Two/9BSaOek-cowboy-bebop-backgrounds.jpg"
}
packages/@uppy/provider-views/src/ProviderView/ProviderView.jsx
Outdated
Show resolved
Hide resolved
packages/@uppy/provider-views/src/ProviderView/ProviderView.jsx
Outdated
Show resolved
Hide resolved
Co-authored-by: Merlijn Vos <merlijn@soverin.net>
if you in the UI select (checkbox) a directory inside a directory, they will be different. example: |
Okay makes sense. We should document that here: https://uppy.io/docs/uppy/#working-with-uppy-files. |
created a pr to document metadata: transloadit/uppy.io#138 |
| Package | Version | Package | Version | | ---------------------- | ------- | ---------------------- | ------- | | @uppy/aws-s3-multipart | 3.5.0 | @uppy/locales | 3.2.3 | | @uppy/box | 2.1.2 | @uppy/onedrive | 3.1.2 | | @uppy/companion | 4.7.0 | @uppy/provider-views | 3.4.0 | | @uppy/companion-client | 3.2.1 | @uppy/react | 3.1.3 | | @uppy/core | 3.3.1 | @uppy/status-bar | 3.2.2 | | @uppy/dashboard | 3.4.2 | @uppy/transloadit | 3.2.0 | | @uppy/dropbox | 3.1.2 | @uppy/utils | 5.4.1 | | @uppy/google-drive | 3.2.0 | uppy | 3.12.0 | - @uppy/transloadit: fix error message (Antoine du Hamel / #4572) - @uppy/provider-views: add support for remote file paths (Mikael Finstad / #4537) - @uppy/transloadit: implement Server-sent event API (Antoine du Hamel / #4098) - @uppy/aws-s3-multipart: add support for signing on the client (Antoine du Hamel / #4519) - @uppy/react: allow `id` from props (Merlijn Vos / #4570) - @uppy/aws-s3-multipart: fix lint warning (Antoine du Hamel / #4569) - @uppy/status-bar: listen to `upload` event instead of button click (Antoine du Hamel / #4563) - @uppy/aws-s3-multipart: fix support for non-multipart PUT upload (Antoine du Hamel / #4568) - @uppy/companion: fix esm imports in production/transpiled builds (Dominik Schmidt / #4561) - @uppy/locales: fix expression and spelling errors in es_ES (Rubén / #4567) - meta: upgrade dev dependencies (dependabot\[bot\]) - meta: Don't use triage label (Artur Paikin / #4552) - meta: update Cypress (Antoine du Hamel / #4562) - @uppy/box,@uppy/companion,@uppy/dropbox,@uppy/google-drive,@uppy/onedrive,@uppy/provider-views: Load Google Drive / OneDrive lists 5-10x faster & always load all files (Merlijn Vos / #4513) - @uppy/locales: Add missing pt-BR locales for ImageEditor plugin (Mateus Cruz / #4558)
Hoooray! 🎉 Thanks a lot, everyone |
* main: @uppy/aws-s3-multipart: refresh file before calling user-defined functions (#4557) Release: uppy@3.13.0 (#4595) Add i18n to CONTRIBUTING.md (#4591) Add VirtualList to ProviderView (#4566) @uppy/provider-views: fix race conditions with folder loading (#4578) @uppy/status-bar: fix ETA when status bar is installed during upload (#4588) @uppy/provider-views: fix infinite folder loading (#4590) examples/aws: client-side signing (#4463) Bump word-wrap from 1.2.3 to 1.2.4 (#4586) e2e: increase `requestTimeout` to 16s (#4587) @uppy/locales: update zh_TW translation (#4583) @uppy/aws-s3-multipart: fix crash on pause/resume (#4581) @uppy/aws-s3-multipart: do not access `globalThis.crypto` on the top-level (#4584) Release: uppy@3.12.0 (#4574) @uppy/transloadit: fix error message (#4572) @uppy/provider-views: add support for remote file paths (#4537) @uppy/transloadit: implement Server-sent event API (#4098)
implemented similar to local files (
meta.relativePath
)closes #4486 #4034
related #2605