Code Monkey home page Code Monkey logo

sumo's Introduction

Sumo

Sumo is a library that prepares for fast upload for iOS. It is effective when uploading by selecting images continuously. Sumo will prepare for uploading immediately after the image is selected. Multiple selected images are compiled into one file and compressed. One compressed file can communicate without overhead.

Feature 🎉

  • ☑️ Non blocking Main thread.
  • ☑️ Fast resizing.
  • ☑️ Task is cancelable.
  • ☑️ Multi sessions.

Usage

Sumo consists of sessions and tasks. Multiple tasks are associated with one session, and you can obtain obtain artifacts by zip the session.

override func viewDidLoad() {
    super.viewDidLoad()
    var options: Sumo.Session.Options = Sumo.Session.Options()
    // Target of image resizing
    options.imageTargetSize = CGSize(width: 500, height: 500)
    Sumo.shared.startSession(options: options)
}

For example in CollectionView's

  • func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath)
  • func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath)
// Compress and process the image in the background.
func didSelectItem(indexPath: IndexPath, asset: PHAsset) {
    Sumo.shared.startWorflow(asset.localIdentifier) { (error) in
        if let error = error {
            debugPrint(error)
            return
        }
    }
}

// Cancel the image being compressed.
func didDeselectItem(indexPath: IndexPath, asset: PHAsset) {
    Sumo.shared.cancel(asset.localIdentifier)
}
// Stop all processing.
@objc private func cancel() {
    Sumo.shared.stop()
}

// Cancel the task being processed. The session will continue to remain.
@objc private func reset() {
    Sumo.shared.reset()
}

// Compress the resized photo to zip.
@objc private func zip() {
    Sumo.shared.zip { (url, error) in
        // Transfer to any server.
    }
}

AssemblyLine is generalized to Sumo.

sumo's People

Contributors

1amageek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.