STFTPNetwork 0.0.2

STFTPNetwork 0.0.2

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Aug 2018

Maintained by Suta.



  • By
  • Suta

STFTPNetwork

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.