Skip to content

macabeus/RuAWSS3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RuAWSS3

CI Status Version License Platform

Since AWS's official library is extremely complicated, I decided to make one to simplify the work. All asynchrony is performed using PromiseKit. You need to know the concept of promise; if you don't know, see it.

alt text

Run the example project

  1. Clone the repo
  2. Run pod install from the Example directory first
  3. Open AppDelegate.swift
  4. Update application(_:didFinishLaunchingWithOptions) with your Amazon's credentials

Installation

RuAWSS3 is available through CocoaPods. To install it, add the following line to your Podfile:

pod 'RuAWSS3', '~> 0.1.0-beta'

And, add in your AppDelegate.swift:

import RuAWSS3
...

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

  AmazonS3.shared.performCredentials(
      regionType: ** YOUR REGION **,
      identityPoolId: ** YOUR POOL ID **
  )
  
  return true
}

Usage

Firstly, you need import this modules:

import PromiseKit
import RuAWSS3

Upload image

firstly {
    AmazonS3.shared.uploadImage(
        bucket: "example",
        key: "image.jpg",
        image: UIImage(named: "example")!
    )
}.then {
    print("succes õ/")
}.catch { error in
    print("fail ;-;")
    print((error as NSError).localizedDescription)
}

Download image

firstly {
    AmazonS3.shared.download(
        bucket: "example",
        key: "image.jpg"
    )
}.then { filePath -> Void in
    print("succes õ/")
    self.imgView.image = UIImage(contentsOfFile: filePath)!
}.catch { error in
    print("fail ;-;")
    print((error as NSError).localizedDescription)
}

Delete file

firstly {
    AmazonS3.shared.delete(
        bucket: "example",
        key: "image.jpg"
    )
}.then {
    print("succes õ/")
}.catch { error in
    print("fail ;-;")
    print((error as NSError).localizedDescription)
}

You can see others amazing examples in Example application.

Author

Macabeus, [email protected]

License

RuAWSS3 is available under the MIT license. See the LICENSE file for more info.