Skip to content

Commit

Permalink
code clean
Browse files Browse the repository at this point in the history
  • Loading branch information
lixian committed Oct 11, 2017
1 parent 9527707 commit e562fb5
Showing 1 changed file with 75 additions and 84 deletions.
159 changes: 75 additions & 84 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
LxFTPRequest
============

Installation
------------
Only need add LxFTPRequest.h and LxFTPRequest.m to your project.

Introduction
------------
A convenient FTP Request library. Support progress tracking, Breakpoint continuingly etc.
Expand All @@ -15,32 +17,31 @@ Support
Both support iOS and Mac OS X platforms.
Minimum support iOS version: iOS 5.0
Minimum support OS X version: Mac OS X 10.7

Podfile
------------
pod 'LxFTPRequest', '~> 1.0.0'
pod 'LxFTPRequest', '~> 1.1.1'

How to use
-----------
#import "LxFTPRequest.h"
### Get resource list:

LxFTPRequest * request = [LxFTPRequest resourceListRequest];
request.serverURL = [[NSURL URLWithString:FTP_SCHEME_HOST]URLByAppendingPathComponent:SUB_DIRECTORY];
request.username = USERNAME;
request.password = PASSWORD;
request.progressAction = ^(NSInteger totalSize, NSInteger finishedSize, CGFloat finishedPercent) {
NSLog(@"totalSize = %ld, finishedSize = %ld, finishedPercent = %f", totalSize, finishedSize, finishedPercent);
};
request.successAction = ^(Class resultClass, id result) {
NSArray * resultArray = (NSArray *)result;
NSLog(@"resultArray = %@", resultArray);
};
request.failAction = ^(CFStreamErrorDomain domain, NSInteger error, NSString *errorMessage) {
NSLog(@"domain = %ld, error = %ld", domain, error);
};
[request start];
LxFTPRequest * request = [LxFTPRequest resourceListRequest];
request.serverURL = [[NSURL URLWithString:FTP_SCHEME_HOST]URLByAppendingPathComponent:SUB_DIRECTORY];
request.username = USERNAME;
request.password = PASSWORD;
request.progressAction = ^(NSInteger totalSize, NSInteger finishedSize, CGFloat finishedPercent) {
NSLog(@"totalSize = %ld, finishedSize = %ld, finishedPercent = %f", totalSize, finishedSize, finishedPercent);
};
request.successAction = ^(Class resultClass, id result) {
NSArray * resultArray = (NSArray *)result;
NSLog(@"resultArray = %@", resultArray);
};
request.failAction = ^(CFStreamErrorDomain domain, NSInteger error, NSString *errorMessage) {
NSLog(@"domain = %ld, error = %ld", domain, error);
};
[request start];

### Download resource:

Expand All @@ -54,85 +55,75 @@ How to use
[[NSFileManager defaultManager]removeItemAtPath:LOCAL_FILE_PATH error:&error];
*/

LxFTPRequest * request = [LxFTPRequest downloadRequest];
request.serverURL = [NSURL URLWithString:FTP_RESOURCE_ADDRESS];
request.localFileURL = [NSURL fileURLWithPath:LOCAL_FILE_PATH];
request.username = USERNAME;
request.password = PASSWORD;
request.progressAction = ^(NSInteger totalSize, NSInteger finishedSize, CGFloat finishedPercent) {
NSLog(@"totalSize = %ld, finishedSize = %ld, finishedPercent = %f", totalSize, finishedSize, finishedPercent);
};
request.successAction = ^(Class resultClass, id result) {
NSLog(@"resultClass = %@, result = %@", resultClass, result);
};
request.failAction = ^(CFStreamErrorDomain domain, NSInteger error, NSString *errorMessage) {
NSLog(@"domain = %ld, error = %ld", domain, error);
};
[request start];
LxFTPRequest * request = [LxFTPRequest downloadRequest];
request.serverURL = [NSURL URLWithString:FTP_RESOURCE_ADDRESS];
request.localFileURL = [NSURL fileURLWithPath:LOCAL_FILE_PATH];
request.username = USERNAME;
request.password = PASSWORD;
request.progressAction = ^(NSInteger totalSize, NSInteger finishedSize, CGFloat finishedPercent) {
NSLog(@"totalSize = %ld, finishedSize = %ld, finishedPercent = %f", totalSize, finishedSize, finishedPercent);
};
request.successAction = ^(Class resultClass, id result) {
NSLog(@"resultClass = %@, result = %@", resultClass, result);
};
request.failAction = ^(CFStreamErrorDomain domain, NSInteger error, NSString *errorMessage) {
NSLog(@"domain = %ld, error = %ld", domain, error);
};
[request start];
### Upload resource:

LxFTPRequest * request = [LxFTPRequest uploadRequest];
request.serverURL = [NSURL URLWithString:FTP_SCHEME_HOST]URLByAppendingPathComponent:FILE_PATH];
request.localFileURL = [NSURL fileURLWithPath:LOCAL_FILE_SAVE_PATH];
request.username = USERNAME;
request.password = PASSWORD;
request.progressAction = ^(NSInteger totalSize, NSInteger finishedSize, CGFloat finishedPercent) {
NSLog(@"totalSize = %ld, finishedSize = %ld, finishedPercent = %f", totalSize, finishedSize, finishedPercent);
};
request.successAction = ^(Class resultClass, id result) {
NSLog(@"resultClass = %@, result = %@", resultClass, result);
};
request.failAction = ^(CFStreamErrorDomain domain, NSInteger error, NSString *errorMessage) {
NSLog(@"domain = %ld, error = %ld", domain, error);
};
[request start];
LxFTPRequest * request = [LxFTPRequest uploadRequest];
request.serverURL = [NSURL URLWithString:FTP_SCHEME_HOST]URLByAppendingPathComponent:FILE_PATH];
request.localFileURL = [NSURL fileURLWithPath:LOCAL_FILE_SAVE_PATH];
request.username = USERNAME;
request.password = PASSWORD;
request.progressAction = ^(NSInteger totalSize, NSInteger finishedSize, CGFloat finishedPercent) {
NSLog(@"totalSize = %ld, finishedSize = %ld, finishedPercent = %f", totalSize, finishedSize, finishedPercent);
};
request.successAction = ^(Class resultClass, id result) {
NSLog(@"resultClass = %@, result = %@", resultClass, result);
};
request.failAction = ^(CFStreamErrorDomain domain, NSInteger error, NSString *errorMessage) {
NSLog(@"domain = %ld, error = %ld", domain, error);
};
[request start];

### Create file or directory on ftp server:

LxFTPRequest * request = [LxFTPRequest createResourceRequest];
request.serverURL = [NSURL URLWithString:FTP_RESOURCE_PATH]; // directory path should be end up with '/'
request.username = USERNAME;
request.password = PASSWORD;
request.successAction = ^(Class resultClass, id result) {
NSLog(@"resultClass = %@, result = %@", resultClass, result);
};
request.failAction = ^(CFStreamErrorDomain domain, NSInteger error, NSString *errorMessage) {
NSLog(@"domain = %ld, error = %ld", domain, error);
};
[request start];
LxFTPRequest * request = [LxFTPRequest createResourceRequest];
request.serverURL = [NSURL URLWithString:FTP_RESOURCE_PATH]; // directory path should be end up with '/'
request.username = USERNAME;
request.password = PASSWORD;
request.successAction = ^(Class resultClass, id result) {
NSLog(@"resultClass = %@, result = %@", resultClass, result);
};
request.failAction = ^(CFStreamErrorDomain domain, NSInteger error, NSString *errorMessage) {
NSLog(@"domain = %ld, error = %ld", domain, error);
};
[request start];

### Delete file or directory on ftp server:

/**
The directory which is not empty CANNOT BE DELETED !!!
CANNOT DELETE EMPTY DIRECTORY!!!
*/

LxFTPRequest * request = [LxFTPRequest destoryResourceRequest];
request.serverURL = [NSURL URLWithString:FTP_RESOURCE_PATH];
request.username = USERNAME;
request.password = PASSWORD;
request.successAction = ^(Class resultClass, id result) {
NSLog(@"resultClass = %@, result = %@", resultClass, result);
};
request.failAction = ^(CFStreamErrorDomain domain, NSInteger error, NSString *errorMessage) {
NSLog(@"domain = %ld, error = %ld", domain, error);
};
[request start];
LxFTPRequest * request = [LxFTPRequest destoryResourceRequest];
request.serverURL = [NSURL URLWithString:FTP_RESOURCE_PATH];
request.username = USERNAME;
request.password = PASSWORD;
request.successAction = ^(Class resultClass, id result) {
NSLog(@"resultClass = %@, result = %@", resultClass, result);
};
request.failAction = ^(CFStreamErrorDomain domain, NSInteger error, NSString *errorMessage) {
NSLog(@"domain = %ld, error = %ld", domain, error);
};
[request start];
Be careful
-----------
Demo must config FTP address, username, password correctly.

License
-----------
LxFTPRequest is available under the Apache License 2.0. See the LICENSE file for more info.
Expand Down

0 comments on commit e562fb5

Please sign in to comment.