Latest 0.0.2
Homepage https://github.com/shien7654321/STFTPNetwork
License MIT
Platforms ios 8.0, requires ARC
Frameworks Foundation, UIKit
Authors

Version
License
Platform

A simple FTP network library for iOS.

STFTPNetwork is an FTP network library for iOS.You can use it to connect to the FTP server, manage your files, including query, create, delete, download, upload and other operations.

STFTPNetworkPreview01

Requirements

  • iOS 8.0 or later (For iOS 8.0 before, maybe it can work, but I have not tested.)
  • ARC

Installation

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

pod 'STFTPNetwork'

Usage

Import headers in your source files

In the source files where you need to use the library, import the header file:

#import <STFTPNetwork/STFTPNetwork.h>

Connect to FTP Server

Use the following function to connect to FTP server:

[STFTPNetwork connect:@"ftp://xxxx:xxxx" username:@"xxxx" password:@"xxxx" handler:^(BOOL success) {
    NSLog(@"Connect FTP server success");
}];

Query files

Use the following function to query files:

[STFTPNetwork query:@"ftp://xxxx:xxxx/xxxx" successHandler:^(NSArray *results) {
    NSLog(@"Query files success: %@", results);
} failHandler:^(STFTPErrorCode errorCode) {
    NSLog(@"Query files failed: %ld", (long)errorCode);
}];

New folder

Use the fillowing function to new folder:

[STFTPNetwork create:@"ftp://xxxx:xxxx/xxxx" successHandler:^{
    NSLog(@"New folder success");
} failHandler:^(STFTPErrorCode errorCode) {
    NSLog(@"New folder failed: %ld", (long)errorCode);
}];

Delete file or folder

Use the following function to delete file or folder:

[STFTPNetwork remove:@"ftp://xxxx:xxxx/xxxx" successHandler:^{
    NSLog(@"Delete file success");
} failHandler:^(STFTPErrorCode errorCode) {
    NSLog(@"Delete file failed: %ld", (long)errorCode);
}];

Download file

Use the following function to download file:

[STFTPNetwork download:@"ftp://xxxx:xxxx/xxxx" progressHandler:^(unsigned long long bytesCompleted, unsigned long long bytesTotal) {
    NSLog(@"Download progress: %.2f%%", bytesTotal > 0 ? bytesCompleted * 100.0 / bytesTotal : 0);
} successHandler:^(NSData *data) {
    NSLog(@"Download file success: %@", data);
} failHandler:^(STFTPErrorCode errorCode) {
    NSLog(@"Download file failed: %ld", (long)errorCode);
}];

Upload file

Use the following function to upload file:

[STFTPNetwork upload:localFilePath urlString:@"ftp://xxxx:xxxx/xxxx" progressHandler:^(unsigned long long bytesCompleted, unsigned long long bytesTotal) {
    NSLog(@"Upload progress: %.2f%%", bytesTotal > 0 ? bytesCompleted * 100.0 / bytesTotal : 0);
} successHandler:^{
    NSLog(@"Upload file success");
} failHandler:^(STFTPErrorCode errorCode) {
    NSLog(@"Upload file failed: %ld", (long)errorCode);
}];

Disconnect FTP server

Use the following function to disconnect FTP server:

[STFTPNetwork disconnect];

Author

Suta, [email protected]

License

MIT license.

Latest podspec

{
    "name": "STFTPNetwork",
    "version": "0.0.2",
    "summary": "An FTP network library for iOS.",
    "homepage": "https://github.com/shien7654321/STFTPNetwork",
    "authors": {
        "Suta": "[email protected]"
    },
    "source": {
        "git": "https://github.com/shien7654321/STFTPNetwork.git",
        "tag": "0.0.2"
    },
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "frameworks": [
        "Foundation",
        "UIKit"
    ],
    "source_files": "STFTPNetwork/*.{h,m}",
    "compiler_flags": "-fmodules",
    "description": "STFTPNetwork is an FTP network library for iOS."
}

Pin It on Pinterest

Share This