Giter VIP home page Giter VIP logo

beamer's Introduction

Beamer

Beamer is an upload manager framework for iOS applications.

Requirements

  • iOS 9+
  • Swift 4

Key Features

  • Supports background uploads.
  • Saves upload status of each file, internally
  • Operation based requests
  • Block based implementation
  • Extensive notification support for operation status
  • Cancellable operations
  • Supports multiple asynchronous uploads

Dependencies

Beamer is an AWS based upload manager, so you have to get AWS credentials and create a model for it.

Beamer has dependency for AWSS3 library to use AWS's core functionalities.

Installation

Beamer uses CocoaPods, a library dependency management tool for iOS projects. Implementing Beamer into your project is as simple as adding the following line to your Podfile,

pod 'Beamer'

Then, run pod install in your project directory.

Make sure to use the .xcworkspace file from now on.

Usage

Beamer has dependency AWSS3 so, you should provide AWSCredentialPermissionS3 and AWSCredential otherwise library will give fatal error.

AWSCredentialPermissionS3(bucketName: String,
    uploadPath: String,
    regionName: String)
AWSCredential(regionType: AWSRegionType,
    permission: AWSCredentialPermissionS3,
    identityPoolID: String,
    token: String,
    identityID: String,
    providerName: String)

After providing AWSCredential you need to register it on AppDelegate.swift's application(_:didFinishLaunchingWithOptions:) method

func application(_ application: UIApplication,
                 didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    ...
    Beamer.shared.register(awsCredential: awsCredentialModel)
    ...
    return true
}

For creating uploadable items, you need to conform Uploadable protocol for UploadTask.

You will append uploadable item with UploadTask class.

UploadTask(file: Uploadable,
    directoryName: String,
    fileName: String,
    identifier: Int)

Optional

If your app supports background uploads, you need to call Beamer's method on AppDelegate.swift's application(_:handleEventsForBackgroundURLSession:completionHandler:) method

func application(_ application: UIApplication,
                 handleEventsForBackgroundURLSession identifier: String,
                 completionHandler: @escaping () -> Void) {
    Beamer.shared.handleBackgroundEvents(application: application, identifier: identifier, completionHandler: completionHandler)
}

After setting up, you can upload item wherever you are.

Beamer.shared.add(uploadTask: uploadTask)

Observation

You can get upload information by adding observers. Firstly, you need to conform BeamerObserver protocol. Then add it to Beamer.

Beamer.shared.addObserver(self)

You will get callbacks

  • When upload task starts:
func beamer(_ beamer: Beamer, 
            didStart uploadTask: UploadTask)
  • When upload progress changes:
func beamer(_ beamer: Beamer, 
            didUpdate progress: Float,
            uploadTask: UploadTask)
  • When an upload task is completed:
func beamer(_ beamer: Beamer, 
            didFinish uploadTask: UploadTask)
  • When an upload task fails:
func beamer(_ beamer: Beamer, 
            didFail uploadTask: UploadTask, 
            error: Error)

You can easily remove your observer from Beamer with

Beamer.shared.removeObserver(self)

Credits

Beamer is brought to you by Hipo Team.

License

Beamer is licensed under the terms of the Apache License, version 2.0. Please see the LICENSE file for full details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.