Call getShares method to list shares created for files or folders in a user’s Personal Cloud Storage account. Use deleteShares method to delte the specified share.
CloudAPI
class object with the application key, secret and the callback URL you obtained from the ThingSpace portal.CloudAPI#authorize()
.Code Sample
try { ArrayList<ShareResource> shareResources = new ArrayList<>(); for (int count=0; count<fullviewList.getCount(); count++) { FullviewItem fullviewItem = fullviewList.getItem(count); ShareResource resource = new ShareResource(); resource.setName(fullviewItem.getName()); resource.setLocation(fullviewItem.getUri()); resource.setSize(fullviewItem.getSize()); resource.setType("file"); resource.setSubType("image"); shareResources.add(resource); } Share share = cloudAPI.createShare(contextWeakReference.get(), "New Share 1", 0, shareResources); Log.d("Create Share", "New Share UID: " + share.getUid()); } catch (CloudAPIException cloudAPIException) { if (cloudAPIException.getCode() == CloudAPIException.ErrorCode.USER_UNAUTHORIZED) { Log.d("Create Share", "User not authorized, please call CloudAPI#authorize()"); } }
The following code sample deletes a specified share using shareUid. shareUid
is a unique share identifier included in the response to getShares call.
CloudAPI
class object with the application key, secret and the callback URL you obtained from the ThingSpace portal.CloudAPI#authorize()
.Code Sample
try { boolean deleteSuccess = cloudAPI.deleteShares(context, shareUid); if (deleteSuccess) { Log.d("Shares", "Share Deleted"); } } catch (CloudAPIException cloudAPIException) { if (cloudAPIException.getCode() == CloudAPIException.ErrorCode.USER_UNAUTHORIZED) { Log.d("Delete Shares", "User not authorized, please call CloudAPI#authorize()"); } }
CloudAPI
class object with the application key, secret and the callback URL you obtained from the ThingSpace portal.CloudAPI#authorize()
.The following code sample illustrates two examples: - How to retrieve shared created between two specified dates. - How to retrieve all shares in a user’s Personal Cloud Storage account.
Code Sample
The following code sample allows you to retrieve all shares created between specified dates.
try { ItemList<Share> itemListShares = cloudAPI.getShares(context, "2016-01-01T12:00:00Z", "2016-05-05T13:15:30Z"); for (int shareCounter=0; shareCounter<itemListShares.getCount(); shareCounter++) { Share share = itemListShares.getItem(shareCounter); Log.d("Share", "Name: " + share.getName() + " - UID:" + share.getUid()); ItemList<Share.Resource> resourceList = share.getResources(); for (int resourceCounter=0; resourceCounter<resourceList.getCount(); resourceCounter++) { Share.Resource resource = resourceList.getItem(resourceCounter); Log.d("Share Resource", "Name: " + resource.getName() + " Url: " + resource.getUrl()); } } } catch (CloudAPIException cloudAPIException) { if (cloudAPIException.getCode() == CloudAPIException.ErrorCode.USER_UNAUTHORIZED) { Log.d("List Share", "User not authorized, please call CloudAPI#authorize()"); } }
NOTE:
To retrieve all shares, replace the following code in the code sample above:
ItemList<Share> itemListShares = cloudAPI.getShares(context, "2016-01-01T12:00:00Z", "2016-05-05T13:15:30Z");
with this code sample:
ItemList<Share> itemListShares = cloudAPI.getShares(context, null, null);
Copyright © 2015-2017, Verizon and/or its Licensors. All rights reserved.