Hi,

You might need to re-pass the user name and password when doing the
download call. Not sure why the authentication from the first call isn't
kept for the second one. Is your client keeping the cookies ?

Another idea: you could try passing the header "OCS-APIREQUEST" set to
true in your OCS API call like it's done here:
https://github.com/owncloud/core/blob/master/apps/files_sharing/js/sharedfilelist.js#L116

This might somehow tell the OCS API code to keep the session, if I
remember correctly.

Cheers,

Vincent

On 08/18/2014 06:15 AM, Jeff Fearn 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.
> _______________________________________________
> Devel mailing list
> [email protected]
> http://mailman.owncloud.org/mailman/listinfo/devel
> 

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

Reply via email to