{"id":885,"date":"2020-03-24T17:01:50","date_gmt":"2020-03-24T17:01:50","guid":{"rendered":"https:\/\/dev.i-smartcloud.com\/?page_id=885"},"modified":"2020-09-28T21:18:29","modified_gmt":"2020-09-28T21:18:29","slug":"cloud-manager-android","status":"publish","type":"page","link":"https:\/\/dev.i-smartcloud.com\/index.php\/cloud-manager-android\/","title":{"rendered":"Cloud Manager"},"content":{"rendered":"\n<p>These classes have all the code that we need to manage the supported Cloud Services. There is code to list items, rename a file, delete a file, delete a folder, download a file, upload a file, and get information for the logged in user. <\/p>\n\n\n\n<p>We create an instance of that class by calling the constructor RManager(RServiceItem _serviceItem):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>RManager rManager = new RManager(RServiceItem _serviceItem);<\/code><\/pre>\n\n\n\n<p>where rService is an instance of the <a href=\"https:\/\/dev.i-smartcloud.com\/index.php\/serviceitem-android\/\">ServiceItem<\/a> class. <\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>Even though we can create an instance of the Cloud Manager class by calling the default constructor, we strongly advise against it. The instance of the ServiceItem class that we pass to the Cloud Manager class has all the information that we need to authenticate the user when we make a request to that Cloud Service.<\/p><\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">Methods<\/h2>\n\n\n\n<p>The Cloud Manager has several methods. Some of them are used internally, but there are some that we need to call in order to manage that Cloud Service:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>getFilesInFolder<\/strong>(String path): Get the list of items (files and folders) in a folder. The path is the <a href=\"https:\/\/dev.i-smartcloud.com\/index.php\/item\/\">rItem.path<\/a>. We get the response from the method <strong>filesListIsReady<\/strong> of the <strong>RManagerCallback<\/strong> callback<\/li><li><strong>searchItemsInFolder<\/strong>:(String<em> <\/em>path<em>, String <\/em>key, SearchTypes type): Search for files and folders in a folder. The path is the <a href=\"https:\/\/dev.i-smartcloud.com\/index.php\/item\/\">rItem.path<\/a>. We get the response from the method <strong>filesListIsReady<\/strong> of the <strong>RManagerCallback<\/strong> callback. The SearchType is an enum with the following two values:<ul><li><strong>stFile<\/strong>: Returns files\/folders whose name matches the key<\/li><li><strong>stFileAndContent<\/strong>: Return files\/folders whose name matches the key, but also returns file(s) whose content contains that key<\/li><\/ul><\/li><li><strong>downloadFile<\/strong>(RItem file): We call this method to download a file. We get the response from the <strong>onFileToBeDownloaded<\/strong> of the <strong>RManagerDownloadCallback<\/strong> callback.<\/li><li><strong>uploadLocalFile<\/strong>(RItem file, String path): We call this method to upload a file to a folder. The path is the rItem.path of that folder. We get the response from the method <strong>onFileIsReadyToBeUploaded<\/strong> of the <strong>RManagerTransferCallback<\/strong> callback<\/li><li><strong>deleteFile<\/strong>(RItem file): A method to delete a file. We get the response from the method <strong>ioTaskCompletedWithResponse<\/strong> of the <strong>RManagerCallback<\/strong> callback<\/li><li><strong>deleteFolder<\/strong>(RItem folder): A method to delete a folder. It does not delete the folder recursively. You need to delete the files subfolders that are contained in that folder. We get the response from the method <strong>ioTaskCompletedWithResponse<\/strong> of the <strong>RManagerCallback<\/strong> callback<\/li><li><strong>renameFile<\/strong>(RItem file, String fileName): A method to rename a file. We get the response from the method <strong>ioTaskCompletedWithResponse<\/strong> of the <strong>RManagerCallback<\/strong> callback<\/li><li><strong>createFolder<\/strong>(String folderName, String parentFolder): A method to create a new folder (named folderName) in the  parentFolder path. We get the response from the method <strong>ioTaskCompletedWithResponse<\/strong> of the <strong>RManagerCallback<\/strong> callback<\/li><\/ul>\n\n\n\n<p>We always call the method <strong>uploadLocalFile<\/strong> to upload a file, regardless of the file size. If it is needed, the Rainbow SDK will create a session and upload that file in chunks.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Callbacks<\/h2>\n\n\n\n<p>The Cloud Manager class uses the following delegates:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>RManagerCallback<\/strong>:<ul><li><strong>filesListIsReady<\/strong>(ArrayList&lt;RItem> items): This method is called when the SDK has the list of items (files and folders) in the selected folder (either because we browsed that folder or we searched in that folder)<\/li><li><strong>somethingWasWrong<\/strong>: This method is called every time there was a problem with a request<\/li><li><strong>ioTaskCompletedWithResponse<\/strong>(String newID, CloudManagerActions action): This method is called when we make a request to rename a file, delete a file (or folder) and create a new folder. The action will inform us about the action that took place. When we create a new folder, the newID is the itemID of that folder. In all other cases it is an empty string<\/li><\/ul><\/li><li><strong>RManagerTransferCallback<\/strong>:<ul><li><strong>onFileIsReadyToBeUploaded<\/strong>:(RItem file, RTransferItem transferItem, booleaan status): This method is called when we call the method to upload a file. The object transferItem has all the information that we need to upload that file. The status is a flag to indicate if the process was successful or not. You shouldn&#8217;t use the transferItem if that flag is NO.<\/li><\/ul><\/li><li><strong>RManagerDownloadCallback<\/strong>:<ul><li><strong>onFileToBeDownloaded<\/strong>(RTransferItem transferItem): The object transferItem has all the information that we need to download a file<\/li><\/ul><\/li><li><strong>RManagerAccountCallback<\/strong><ul><li><strong>onAccount<\/strong>(RAccount raccount):The object <a href=\"https:\/\/dev.i-smartcloud.com\/index.php\/raccount\/\">rAccount<\/a> has some information about the logged in user.<\/li><\/ul><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<p>The Rainbow SDK has a Cloud Manager class for each supported Cloud Service.  The RLocalManager class is used to save a file on the local filesystem or to upload a local file to a Cloud Service. We give the path of the local file to the property <strong>filePath<\/strong>.<\/p>\n\n\n\n<p>We believe that you would never need to call the methods to upload and download a file. Instead you should create an instance of the <a href=\"https:\/\/dev.i-smartcloud.com\/index.php\/transfer-android\/\">RTransfer<\/a> class, and let it do the hard work of uploading or downloading a file.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>These classes have all the code that we need to manage the supported Cloud Services. There is code to list items, rename a file, delete a file, delete a folder,&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"class_list":["post-885","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Cloud Manager - Rainbow SDK<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/dev.i-smartcloud.com\/index.php\/cloud-manager-android\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Cloud Manager - Rainbow SDK\" \/>\n<meta property=\"og:description\" content=\"These classes have all the code that we need to manage the supported Cloud Services. There is code to list items, rename a file, delete a file, delete a folder,...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/dev.i-smartcloud.com\/index.php\/cloud-manager-android\/\" \/>\n<meta property=\"og:site_name\" content=\"Rainbow SDK\" \/>\n<meta property=\"article:modified_time\" content=\"2020-09-28T21:18:29+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/dev.i-smartcloud.com\/index.php\/cloud-manager-android\/\",\"url\":\"https:\/\/dev.i-smartcloud.com\/index.php\/cloud-manager-android\/\",\"name\":\"Cloud Manager - Rainbow SDK\",\"isPartOf\":{\"@id\":\"https:\/\/dev.i-smartcloud.com\/#website\"},\"datePublished\":\"2020-03-24T17:01:50+00:00\",\"dateModified\":\"2020-09-28T21:18:29+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/dev.i-smartcloud.com\/index.php\/cloud-manager-android\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/dev.i-smartcloud.com\/index.php\/cloud-manager-android\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/dev.i-smartcloud.com\/index.php\/cloud-manager-android\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/dev.i-smartcloud.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Cloud Manager\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/dev.i-smartcloud.com\/#website\",\"url\":\"https:\/\/dev.i-smartcloud.com\/\",\"name\":\"Rainbow SDK\",\"description\":\"The Rainbow Cloud Manager at your disposal\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/dev.i-smartcloud.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Cloud Manager - Rainbow SDK","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/dev.i-smartcloud.com\/index.php\/cloud-manager-android\/","og_locale":"en_US","og_type":"article","og_title":"Cloud Manager - Rainbow SDK","og_description":"These classes have all the code that we need to manage the supported Cloud Services. There is code to list items, rename a file, delete a file, delete a folder,...","og_url":"https:\/\/dev.i-smartcloud.com\/index.php\/cloud-manager-android\/","og_site_name":"Rainbow SDK","article_modified_time":"2020-09-28T21:18:29+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/dev.i-smartcloud.com\/index.php\/cloud-manager-android\/","url":"https:\/\/dev.i-smartcloud.com\/index.php\/cloud-manager-android\/","name":"Cloud Manager - Rainbow SDK","isPartOf":{"@id":"https:\/\/dev.i-smartcloud.com\/#website"},"datePublished":"2020-03-24T17:01:50+00:00","dateModified":"2020-09-28T21:18:29+00:00","breadcrumb":{"@id":"https:\/\/dev.i-smartcloud.com\/index.php\/cloud-manager-android\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/dev.i-smartcloud.com\/index.php\/cloud-manager-android\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/dev.i-smartcloud.com\/index.php\/cloud-manager-android\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/dev.i-smartcloud.com\/"},{"@type":"ListItem","position":2,"name":"Cloud Manager"}]},{"@type":"WebSite","@id":"https:\/\/dev.i-smartcloud.com\/#website","url":"https:\/\/dev.i-smartcloud.com\/","name":"Rainbow SDK","description":"The Rainbow Cloud Manager at your disposal","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/dev.i-smartcloud.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/dev.i-smartcloud.com\/index.php\/wp-json\/wp\/v2\/pages\/885","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.i-smartcloud.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/dev.i-smartcloud.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/dev.i-smartcloud.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.i-smartcloud.com\/index.php\/wp-json\/wp\/v2\/comments?post=885"}],"version-history":[{"count":34,"href":"https:\/\/dev.i-smartcloud.com\/index.php\/wp-json\/wp\/v2\/pages\/885\/revisions"}],"predecessor-version":[{"id":971,"href":"https:\/\/dev.i-smartcloud.com\/index.php\/wp-json\/wp\/v2\/pages\/885\/revisions\/971"}],"wp:attachment":[{"href":"https:\/\/dev.i-smartcloud.com\/index.php\/wp-json\/wp\/v2\/media?parent=885"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}