-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Provide API endpoints for favorites/metadata/tags on files #12337
Comments
Also the question whether it makes sense to limit the "tags" API to just files for the files app that needs it, or make a more generic tags endpoint. For a generic one the issue would be that the result set could be a mix between files and other results (contacts, etc) for a single tag. Maybe the tag management API itself should be generic (get all known tags, delete tags) but not the file-specific ones. |
Summonning @DeepDiver1975 @schiesbn @icewind1991 @ockham for advice/discussion |
Further ideas:
Next step to investigate:
|
this is how we do this as of today for other webdav props: |
@DeepDiver1975 thanks, yes. I think we can return the tags as a new tag On question I'll investigate is whether there's a way to use WebDAV to modify such properties, for example using a PATCH method on the file or use whichever method one can use to store stuff into "oc_properties". |
WebDAV used PROPSET and PROPGET verbs for this
I would not go for that table - highly unstructured and will result in major performance penalties |
I thought about something like "if PROPSET is called with the name 'tags' then use the tags API instead, else store to oc_properties". But maybe that's too hacky ? |
Just to clarify: there is already a Tags API and |
Well - it's an overall design decision we have to take (now?): Do we want the files app to become more and more a webdav client or not? Pros:
Cons:
|
Thing is, I'd love to make the files app use WebDAV only in the long run... we could write a JS WebDAV library that can be reused outside as well and use it in the files app... One drawback mentionned by @icewind1991 is that IE8 might not support WebDAV verbs like PROPFIND properly... Also I believe that list.php is returning information that is currently not available in WebDAV, like "isPreviewAvailable" and others. So might be valid in the long run but not doable right now. For now I'd extend "list.php" to be able to return an extra |
@craigpg @karlitschek I assigned this task to the OC 8 milestone. |
Side note: at some point someone on the dev mailing list asked if there was a JS client for OC so I made this experiment: https://gist.github.com/PVince81/cdfb1287c7f2a2db5f25 |
google gives some results for js webdav - e.g. https://github.com/sara-nl/js-webdav-client |
Could we use PROPPATCH to set the tags properties ? Or is that the same facility like PROPGET/PROPSET ? |
afaik yes - not too sure to be honest - @dragotin should know .. |
I raised #12353 to research/discuss moving the files app to WebDAV in the future. |
I'm still kind of stuck here, what approach should I use ?
|
while I really LOVE to have an REST api - I'd vote against option 3 - we need to manage the zoo of apis and not add more and more - http://www.commitstrip.com/en/page/3/ regarding option 4 - webdav search is a standard which afaik never got implemented anywhere - we had that some month back already in a customer project we either go by option 1 or 2 option 2 contains work which anyhow needs to be done sooner or later just for the sake of code quality/testability - not much lost from a coding point of view option 1 is very promising from an melting-technologies-together-pov - but requires some thinking on how to design this new webdav endpoint I guess short term (OC8) will be option 2 and we continue to think about the pros/cons regarding option 1 these days/weeks |
Thanks a lot for your feedback, makes sense. I'll move the PR to use OCS endpoints instead as soon as the upfront work is ready. |
Thanks you |
@PVince81 I'd like to close this ticket and continue with new ticket(s) from the remaining parts which will go into the direction of OC8.1/OC8.2. What's missing here now? |
The favorites/tags of files can be retrieved with PROPFIND and set with PROPPATCH, so I'd say this task is completed. |
@PVince81 We tried setting Tag using PROPPATCH Code: https://bpaste.net/show/6bd75b2d3512 But, on retrieving with PROPFIND we didn't get any tag Please suggest, |
@lalitesh-infoobjects these are not tags but DAV properties. This is not the same thing. The tags here are about simple tags like "Favorite", "Private", "Important" labels. The thing in your code is a custom DAV property, but your PROPPATCH syntax looks fine. Also please try again with 8.1, I tested it there a while ago and it should work. Not sure about 8.0.x. |
@PVince81 : Updated to 8.1 rc1 Response: |
Please create a new ticket for this issue. Thanks. |
File list
Goal is to make it possible to receive a list of favorite files and/or ids to be able to display them.
Ideal case would be to have everything go over a OCS API and use it internally as well.
Here are three alternatives about how to retrieve the list of files
Currently the list.php ajax call already returns a list of files.
That list could be made filterable by tag using "?tag=tag1" and also make it return a "tags" attribute as part of the result set:
This approach would need a db JOIN with the "vcategory" tables when requesting the files list, might be possible.
The tags would be included in the WebDAV response as extended attributes.
Advantage: all the information is already there, reusing existing endpoint (WebDAV + internal)
Disadantage: performance impact is unclear
GET /ocs/v1.php/apps/files/api/v1/tags/{tagname}?path=path/to/subdir&recursive=false
GET /ocs/v1.php/apps/files/api/v1/favoritefiles?path=path/to/subdir&recursive=false
GET /ocs/v1.php/apps/files/api/v1/favoritefiles?idonly=true&path=path/to/subdir?recursive=false
After rendering the file list with "ajax/list.php" the code must also call the "favoritefiles?idonly=true&path=currentpath" endpoint to get the id of all files inside that folder that have the favorite/tag (similar to what OC.Share does at the moment).
Advantages: No JOIN needed, tags API separate from files (if that's an advantage)
Disadvantages: Cross-reference of files+tags need to be done on the JS side (and API consumer). An external API consumer will need to call WebDAV first to get the file ids, then map it with the result of the tags call.
Tags list
Additional APIs are required to manage the tags themselves:
a) Get all tags for the current user:
GET /ocs/v1.php/apps/files/api/v1/tags?category=files
b) Delete a specific tag for the current user:
DELETE /ocs/v1.php/apps/files/api/v1/tags/{tagname}
Assigning tags to files
Two possibilities:
If we want to do it REST style, we should use the PATCH method and patch the files metadata:
PATCH /ocs/v1.php/apps/files/api/v1/files/path/to/file
and pass a JSON object{tags: ['newtag1', 'newtag2']}
Advantage: REST style
Disadvantage: the endpoint itself doesn't exist (addressing files with files) so it would be added solely for this purpose and also would not be possible to change any other file attribute using that method as it would be expected from a PATCH call (so, might be overkill). If we had a full REST API for the files list it might make sense. But we have WebDAV for that.
Same as before but with "POST"
POST /ocs/v1.php/apps/files/api/v1/files/path/to/file
and pass a JSON object{tags: ['newtag']}
or even less REST:
POST /ocs/v1.php/apps/files/api/v1/settags?path={filePath}&tags=newtag1,newtag2
I heard once that it might be possible to set custom attributes over WebDAV and they would land in the
oc_properties
table. Maybe the same API/endpoint could be used for setting tags on files.Advantages: integrated with WebDAV, no extra strange endpoing as for 1) and 2)
Disadvantages: the files app doesn't use WebDAV so it would need an additional internal endpoint that does exactly the same
The text was updated successfully, but these errors were encountered: