Android library and shared links

Hello everyone, this is the first time I use the Android owncloud library and, even if I'm able to perform classic operations such as create, delete and so on, I'm not able to work with shared links. I first explain what I need to do: my app need to save some data on a owncloud server, but I want to do that thourgh shared links, so that I can create many shared links and every instance of the app will have it own shared link. Now, I would like to be able to access those links without providing any account information. In other words, I would like to reproduce the fact that a user with an account can share a folder (that can be edited) with any other person, even if he does not have an account (you jut give him the link and he can access it).
What I tried to do is to instanciate the api client object by passing the shared link as server address and without setting the credential, but seems to not work.
First question: is it possible to do what I want to achieve?
Second question: I was expecting to be able to access the shared lonk by just substituting the shared link with the server address, but as said, seems to not work... could you please tell me what is the corect procedure to edit shared links?

Thank you

Did you look into the Sharing API description?

@LucaDotti, you can share a file in an ownCloud account with the operation 'CreateRemoteShareOperation', that you will find in the package 'com.owncloud.android.lib.shares'. It's usage is similar to any other operation in the library, you need to create an OwnCloudClient object with the account information and execute and object of 'CreateRemoteShareOperation' through one of its 'executeXXX' methods.

Being more specific, to create a public share (the kind of share that results in a shared link), the second parameter of the constructor of 'CreateRemoteShareOperation' must be the value 'ShareType.PUBLIC_LINK'.

To get the shared link directly in the response of 'CreateRemoteShareOperation', you need to call the method 'setGetShareDetails(true)' in the operation object before executing it via OwnCloudClient. That way, calling 'getData().get(0)' on the 'RemoteOperationResult' object returned in the operation execution, will give an 'OCShare' object with all the information of the share created. The method 'getShareLink()' of this object should return the shared link.

As a reference, you can take a look to this class in the ownCloud Android app, that executes this process using the operation in the library (and some other things): https://github.com/owncloud/android/blob/master/src/com/owncloud/android/operations/CreateShareViaLinkOperation.java#L81

About your second question: there is nothing in the library that can help you with that. The shared links are meant to be displayed in a web browser. You can use them in a regular Android Intent to get them opened in any web browser in the device, or inject them in a WebView. But I don't think you can download the file programmatically from a shared link, there was a hot debate in the past about this since was considered a security risk in some situations. That's why that link leads to a web with a user interface where you need to click a button to download the file.

Hope this helps :slight_smile: