On Mon, Aug 18, 2014 at 2:15 PM, Jeff Fearn <[email protected]> wrote:
> Hi, I'm looking in to using owncloud as a remote backed for file
> syncing in stackedit [1]. i.e. not a hosted app on owncloud.
>
> I'm working on a local host ATM runnig owncloud & stackedit to get
> around CORS. (Bug opened by Jan-Christoph)
>
> I can get the shares list using JS by simply doing:
>
> $.ajax({
>     url: server + '/ocs/v1.php/apps/files_sharing/api/v1/shares?format=json',
>     dataType: "json",
>     username: user,
>     password: pass,
>     timeout: constants.AJAX_TIMEOUT
> })
>
> And then call it again with ''&shared_with_me=true' to get the other shares.
>
> So that's all good, I just need to make it look pretty so the user can
> select what to import in to stackedit.
>
> However, what I can't seem to do is download the files :(
>
> Testing this on one shared file in the root directory.
>
> var download_uri = '/index.php/apps/files/ajax/download.php?dir=/&files='
>
> $.ajax({
>     url: server + download_uri + file,
>     username: user,
>     password: pass,
>     timeout: constants.AJAX_TIMEOUT
> })
>
> This gets me what appears to be the login page, every time :(
>
> I've also tried:
>
> var download_uri = '/index.php/apps/files_texteditor/ajax/loadfile.php?file=';
>
> With this I get:
>
> {"data":{"message":"Authentication
> error","error":"authentication_error"},"status":"error"}
>
> I'm pretty sure it can't be user/password as they are required to get
> the shares list in the first place.
>
> Is there a way to d/l the shared files using ajax?
>
> Cheers, Jeff.

Two further questions:

status: success
jqXHR.status: 200
{
  "data": {
    "message": "Authentication error",
    "error": "authentication_error"
  },
  "status": "error"
}

1: Is it expected that errors are being returned with a status of 200
and not 4xx?

It means I have to embed error handling code in my .done callback
instead of using the normal .fail callback.

Fail to .fail, I'm sure there is a new meme there for someone to play with.

2: Is it expected taht you ahve to login to ownCloud in one tab for an
external app to access ownclouds ajax functions in another tab?

e.g. I have to open owncloud in one tab and stackedit in another tab
to be able to download files ... but I do not need to do this to get
the list of shared files.

Maybe related to CORS?

FWIW if I host owncloud and openstack on the same host, and login in
to owncloud in one tab and stackedit in another, then I can
successfully import multiple files in to stackedit. Need to get my
hard coded stuff to the settings menu, then I'll check my code in to
my github fork. Then on to sync and export.

Cheers, Jeff.
_______________________________________________
Devel mailing list
[email protected]
http://mailman.owncloud.org/mailman/listinfo/devel

Reply via email to