Code Monkey home page Code Monkey logo

sgwifiupload's Introduction

SGWifiUpload

SGWiFiUpload is a tool based on CocoaHTTPServer for iOS to upload files through WiFi. By using this framework, you can upload files easily. It can be used for many locations, such as photos and videos upload.Files will save to Caches by default.

How To GET Started

Installation

Drag the SGWiFiUpload folder to your project.

Usage

Import header

#import "SGWiFiUploadManager.h"

Start server and add observer to process

- (void)setupServer {
    SGWiFiUploadManager *mgr = [SGWiFiUploadManager sharedManager];
    BOOL success = [mgr startHTTPServerAtPort:10086];
    if (success) {
        NSLog(@"URL = %@:%@",mgr.ip,@(mgr.port));
    }
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(fileUploadStart:) name:SGFileUploadDidStartNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(fileUploadFinish:) name:SGFileUploadDidEndNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(fileUploadProgress:) name:SGFileUploadProgressNotification object:nil];
}

#pragma mark Notification Callback
- (void)fileUploadStart:(NSNotification *)nof {
    NSString *fileName = nof.object[@"fileName"];
    NSLog(@"Start Upload <%@>",fileName);
}

- (void)fileUploadFinish:(NSNotification *)nof {
    NSLog(@"File Upload Finished.");
}

- (void)fileUploadProgress:(NSNotification *)nof {
    CGFloat progress = [nof.object[@"progress"] doubleValue];
    NSLog(@"%.2f",progress);
}

- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

Display a WiFi Page on Device

You can use the default WiFi Page to tell users how and where to use it.

WiFi Page

```objective-c [[SGWiFiUploadManager sharedManager] showWiFiPageFrontViewController:self]; ```

Custom Settings

Save Path

You can change the file save location by change the value of savePath in SGWiFiUploadManager.

Web Root

You can change the file save location by change the value of webRoot in SGWiFiUploadManager, the server will search index.html and upload.html in this path.

The count of files to upload

You can change the count of files to upload by modify the index.html in Web Folder. You can add input tag with type="file" in the form whose action is upload.html and method is POST.

sgwifiupload's People

Contributors

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