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

Provide JS Files API classes to access and manipulate files #13905

Closed
PVince81 opened this issue Feb 4, 2015 · 10 comments
Closed

Provide JS Files API classes to access and manipulate files #13905

PVince81 opened this issue Feb 4, 2015 · 10 comments

Comments

@PVince81
Copy link
Contributor

PVince81 commented Feb 4, 2015

Currently apps and file viewers need to resort to their own URL generation schemes and have no direct way of doing file operations like "retrieving the file list" (ex: gallery), "downloading a file", etc.

Instead of having every app or file viewers invent their own way of accessing files, a JS Files API should be developed to provide file operations like:

  • list files in a folder
  • search files
  • download file (when opening a file for vieweing)
  • upload file (when saving a file after modifying it)
  • creating folders
  • deleting files
  • ...

Ideally this API should be implemented base directly WebDAV (see #12353).

Once this API is available, the following will be possible:

  • the files app web UI itself should be based off the JS Files API (Move files app to use WebDAV instead of custom PHP endpoints #12353)
  • other apps or sidebar views can provide their own instance of JS Files API (for example the trashbin can provide a file list of deleted files and let file viewers open such files for viewing)
  • the JS Files API could be used outside of ownCloud by third party apps (with CORS)

@DeepDiver1975 @icewind1991 @schiesbn @MorrisJobke @Raydiation what do you think ?

@PVince81
Copy link
Contributor Author

PVince81 commented Feb 4, 2015

The JS Files API could also be written in a way similar to pyocclient: https://github.com/PVince81/pyocclient
But the question is whether it should also provide other APIs like sharing or such, I'd say no for now.

@DeepDiver1975
Copy link
Member

the JS Files API could be used outside of ownCloud by third party apps (with CORS)

so this files api for javascript is then more a kind of "ownCloud Files SDK for JavaScript" - right?

@PVince81
Copy link
Contributor Author

PVince81 commented Feb 4, 2015

I would say so, yes. A JS SDK designed to run in the browser (not Node JS).

It would be based on WebDAV and contain the workarounds required to upload files in IE 8 or browsers that might not support FormData/FileReader/etc.

The interesting part is that it abstracts away the file access logic and also can be implemented by the trashbin to provide a view to access trashbin files through the same methods.

I still need to think it through to make sure it:

  1. covers the use cases we want when running it inside of ownCloud
  2. not make it too specific so we could at some point extract it as a separate library (like pyocclient) for external apps

@rullzer
Copy link
Contributor

rullzer commented Jun 3, 2015

I can only say this is very welcome!
Similar stuff should be done for sharing, but one step at a time :)

@oparoz
Copy link
Contributor

oparoz commented Oct 4, 2015

+1. Every app is currently using their own controller to do this

@PVince81
Copy link
Contributor Author

PVince81 commented Mar 2, 2016

In OC 9.0 there is now OC.Files.getClient().

However it doesn't support uploading yet, might be tricky though.

@PVince81 PVince81 added this to the backlog milestone Mar 2, 2016
@oparoz
Copy link
Contributor

oparoz commented Mar 2, 2016

I've tested it in Gallery for the move operation and it worked as expected, looking forward to upload :)

@PVince81
Copy link
Contributor Author

PVince81 commented Mar 2, 2016

Upload is very tricky because it requires a hidden "input type=file" field to exist. Also one needs to trigger the file selection dialog by setting the focus on the field to make the browser trigger the dialog.
Not sure how to fit something like this in a simple API like client.upload().

Maybe you have some ideas ? 😄

Note that this PR #21237 brings webdav PUT upload but would need further refactoring to allow cramming the logic into this API.

@PVince81
Copy link
Contributor Author

PVince81 commented Mar 2, 2016

Well, thinking of it, the API might still look simple:

    client.triggerUploadDialog(targetFolder, options).then(function(data) {
        // do stuff after the upload, data contains the uploaded files metadata
    });

The call would have to generate the input field and direclty trigger it to make the dialog appear. Then it would perform the upload into the given targetFolder and eventually calls the callback.

@PVince81
Copy link
Contributor Author

apps could actually use this library: https://github.com/noveens/js-owncloud-client

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants