Skip to content

wenterjoy/swift-cloud-object-storage-example

 
 

Repository files navigation

Build Status Platform

Image Downloader

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

Architecture

  1. 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.

Steps

  1. Clone the repo
  2. Install developer tools
  3. Install dependencies
  4. Create Cloud Object Storage Buckets
  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:

  • iOS 12.0+
  • Xcode 10.0+
  • Swift 4.0+

3. Install dependencies

This code pattern uses Alamofire, Kanna, ZIPFoundation, and SwiftyPlistManager which all work with CocoaPods to manage and configure 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

  1. Provision the IBM Cloud Object Storage Service and follow the set of instructions for creating a Bucket.
  2. Upload the images in atlantic_hurricane_seasons/images to a Bucket.
  3. Run ./zip_hurricane_images.sh in atlantic_hurrincane_seasons/zip to create the zip file. Then upload the zip file to a different Bucket.
  4. Follow these instructions for obtaining an API key and ibm-service-instance-id
  5. 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.

License

This code pattern is licensed under the Apache License, Version 2. Separate third-party code objects invoked within this code pattern are licensed by their respective providers pursuant to their own separate licenses. Contributions are subject to the Developer Certificate of Origin, Version 1.1 and the Apache License, Version 2.

Apache License FAQ

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 98.7%
  • Other 1.3%