More and more technologies are appearing to make functions of an enterprise more efficient. Blockchain technology these days are at the same...
Mobile applications are becoming more prevalent by the day, and more apps are starting to be dependent on cloud storage in order to free up space on the users’ devices. This code pattern will show you how to download images from Cloud Object Storage as well as compare them to images downloaded from a traditional server.
Cloud Object Storage
The IBM Cloud Object Storage provides flexible and easily scalable cloud storage options for unstructured data. Cloud Object Storage makes it possible to store large amounts of data in an efficient manner. With virtually unlimited storage space for data, it is often used for archiving and backup. It is also used for web and mobile applications, and its easy scalability encourages use as persistent storage for analytics. IBM Aspera is pre-integrated to provide a high-speed data transfer to and from Cloud Object Storage, and query-in-place functionality allows easy running of analytics on your stored data.
Mobile applications can often interact with data that is stored in the cloud as objects. This data is stored not only as a backup, storage, and an archive, but also for persistent storage for analytics. As data can be accessed in real time, it allows for the efficient and easy running of analytics on the stored and regularly updated data. In this code pattern, you will create an example Swift application that can be used to compare images that are downloaded from a traditional server, and images that are stored in the Cloud Object Storage.
This mobile app can be used in photo sharing apps, comparison apps, identifier applications, and many more that require storage and/or comparative capabilities. It can also be used to identify similar images, which can have applications in online retail and e-commerce websites. The ease of running analytics also allows data to be processed in real time, which helps increase the efficiency of the organization.
Development and Process Description
This code pattern is an “Image Downloader” app that compares downloaded images from a traditional server (for which one can use any online source of information, for example, Wikipedia) and images from IBM Cloud Object Storage on the phone. The images are stored in the Cloud Object Storage as objects in one bucket and as compressed file archives in another bucket. Hence, in this code pattern, you have to first create an iOS Swift application, as the phone, we are using in this example is an iPhone. After this, you have to integrate the IBM Cloud Object Storage into the aforementioned Swift application.
Once this is done, the user can interact with the Swift app to download the objects (in this case, images) from IBM Cloud Object Storage. The app then makes the relevant calls to the Cloud Object Storage and receives the access token and the list of bucket objects. It will then proceed to download the objects. The images are then downloaded and displayed to the user.
In this Code Pattern, we will look at comparing downloading Atlantic Hurricane Season images from a traditional server (Wikipedia in this case) and Cloud Object Storage on an iPhone. The images are stored in Cloud Object Storage as objects in one Bucket and a Zip archive in another Bucket.
When the reader has completed this Code Pattern, they will understand how to:
- Create an iOS Swift application
- Incorporate Cloud Object Storage into a Swift application
1. The user interacts with the app to start a download of objects (images) from Cloud Object Storage.
2. The app makes the necessary calls to Cloud Object Storage to get the access token, list of bucket objects, and download the objects (images).
3. The images are downloaded and displayed on the app to the user.
5. Run in Xcode
1. Clone the repo
Cone the repo locally. In a terminal, run:
$ git clone https://github.com/IBM/swift-cloud-object-storage-example
$ cd swift-cloud-object-storage-example
2. Install developer tools
Ensure you have the required developer tools installed from Apple:
3. Install dependencies
You can install CocoaPods using the following command:
$ sudo gem install cocoapods
If the CocoaPods repository is not configured, run the following command (this may take a long time depending on your network connection and installation state):
$ pod setup
A pre-configured Podfile has been included in this repository. To download and install the required dependencies, run the following command from your project directory:
$ pod install
If you run into any issues during the pod install, it is recommended to run a pod update by using the following commands:
$ pod update
$ pod install
Finally, open the Xcode workspace: ImageDownloader.xcworkspace.
4. Create Cloud Object Storage Buckets
- Provision the IBM Cloud Object Storage Service and follow the set of instructions for creating a Bucket.
- Upload the images in atlantic_hurricane_seasons/images to a Bucket.
- Run ./zip_hurricane_images.sh in atlantic_hurrincane_seasons/zip to create the zip file. Then upload the zip file to a different Bucket.
- Follow these instructions for obtaining an API key and ibm-service-instance-id
- Include the public endpoint, Bucket names, API key, and ibm-service-instance- id in ImageDownloader/Data.plist
5. Run in Xcode
In Xcode, click Product > Run to start the iOS application. Choose which download type to use for downloading the images from the Picker View. The download history results are logged in the History tab.