{"id":734,"date":"2020-03-11T10:11:49","date_gmt":"2020-03-11T10:11:49","guid":{"rendered":"https:\/\/dev.i-smartcloud.com\/?page_id=734"},"modified":"2020-09-28T21:18:01","modified_gmt":"2020-09-28T21:18:01","slug":"cloud-manager-ios","status":"publish","type":"page","link":"https:\/\/dev.i-smartcloud.com\/index.php\/cloud-manager-ios\/","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 initWithServiceItem:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>RManager *rManager = &#91;&#91;RManager alloc]initWithServiceItem:rServiceItem];<\/code><\/pre>\n\n\n\n<p>where rService is an instance of the <a href=\"https:\/\/dev.i-smartcloud.com\/index.php\/serviceitem-ios\/\">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 init method, 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>:(NSString*)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>RManagerDelegate<\/strong> delegate<\/li><li><strong>searchItemsInFolder<\/strong>:(NSString*)path<em> <\/em><strong>forKey<\/strong><em><strong>:<\/strong>(<\/em>NSString<em>*<\/em>)key <strong>forType:<\/strong>(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> block.<\/li><li><strong>uploadLocalFile<\/strong>:(RItem)file <strong>toPath<\/strong>:(NSString)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>RManagerTransferDelegate<\/strong> delegate<\/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>RManagerDelegate<\/strong> delegate<\/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>RManagerDelegate<\/strong> delegate<\/li><li><strong>renameFile<\/strong>:(RItem)file <strong>toFileName<\/strong>:(NSString)fileName: A method to rename a file. We get the response from the method <strong>ioTaskCompletedWithResponse<\/strong> of the <strong>RManagerDelegate<\/strong> delegate<\/li><li><strong>createFolder<\/strong>:(NSString)folderName <strong>atPath<\/strong>:(NSString)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>RManagerDelegate<\/strong> delegate<\/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\">Delegates<\/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>RManagerDelegate<\/strong>:<ul><li><strong>filesListIsReady<\/strong>: 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). That list is saved in the property <strong>availableFiles<\/strong> of the Cloud Manager instance (this will change in the future)<\/li><li><strong>somethingWasWrong<\/strong>: This method is called every time there was a problem with a request<\/li><li><strong>ioTaskCompletedWithResponse<\/strong>:(NSString*)newID <strong>forAction<\/strong>:(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>RManagerTransferDelegate<\/strong>:<ul><li><strong>onFileIsReadyToBeUploaded<\/strong>:(RItem)file <strong>withSyncObj<\/strong>:(RTransferItem)upObj <strong>andStatus<\/strong>:(BOOL)status: This method is called when we call the method to upload a file. The object upObj 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 upObj if that flag is NO.<\/li><\/ul><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Blocks<\/h2>\n\n\n\n<p>The Cloud Manager also uses the following blocks:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>(^<strong>onFileToBeDownloaded<\/strong>)(RTransferItem *downObj): The object downObj has all the information that we need to download a file<\/li><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>\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-ios\/\">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-734","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-ios\/\" \/>\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-ios\/\" \/>\n<meta property=\"og:site_name\" content=\"Rainbow SDK\" \/>\n<meta property=\"article:modified_time\" content=\"2020-09-28T21:18:01+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-ios\/\",\"url\":\"https:\/\/dev.i-smartcloud.com\/index.php\/cloud-manager-ios\/\",\"name\":\"Cloud Manager - Rainbow SDK\",\"isPartOf\":{\"@id\":\"https:\/\/dev.i-smartcloud.com\/#website\"},\"datePublished\":\"2020-03-11T10:11:49+00:00\",\"dateModified\":\"2020-09-28T21:18:01+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/dev.i-smartcloud.com\/index.php\/cloud-manager-ios\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/dev.i-smartcloud.com\/index.php\/cloud-manager-ios\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/dev.i-smartcloud.com\/index.php\/cloud-manager-ios\/#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-ios\/","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-ios\/","og_site_name":"Rainbow SDK","article_modified_time":"2020-09-28T21:18:01+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-ios\/","url":"https:\/\/dev.i-smartcloud.com\/index.php\/cloud-manager-ios\/","name":"Cloud Manager - Rainbow SDK","isPartOf":{"@id":"https:\/\/dev.i-smartcloud.com\/#website"},"datePublished":"2020-03-11T10:11:49+00:00","dateModified":"2020-09-28T21:18:01+00:00","breadcrumb":{"@id":"https:\/\/dev.i-smartcloud.com\/index.php\/cloud-manager-ios\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/dev.i-smartcloud.com\/index.php\/cloud-manager-ios\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/dev.i-smartcloud.com\/index.php\/cloud-manager-ios\/#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\/734","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=734"}],"version-history":[{"count":45,"href":"https:\/\/dev.i-smartcloud.com\/index.php\/wp-json\/wp\/v2\/pages\/734\/revisions"}],"predecessor-version":[{"id":970,"href":"https:\/\/dev.i-smartcloud.com\/index.php\/wp-json\/wp\/v2\/pages\/734\/revisions\/970"}],"wp:attachment":[{"href":"https:\/\/dev.i-smartcloud.com\/index.php\/wp-json\/wp\/v2\/media?parent=734"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}