1、採用第三方函式庫上傳檔案到ftp時總報錯
2、程式碼:
static NSString * const FTP_ADDRESS = @"ftp://54.223.34.111:21/";
static NSString * const USERNAME = @"123456";
static NSString * const PASSWORD = @"123456";
LxFTPRequest * request = [LxFTPRequest uploadRequest];
request.serverURL = [[NSURL URLWithString:FTP_ADDRESS]URLByAppendingPathComponent:@"./test.txt"];
request.localFileURL = [NSURL fileURLWithPath:fileName];
request.username = USERNAME;
request.password = PASSWORD;
request.progressAction = ^(NSInteger totalSize, NSInteger finishedSize, CGFloat finishedPercent) {
};
request.successAction = ^(Class resultClass, id result) {
NSLog(@"uploadbyftp success");
};
request.failAction = ^(CFStreamErrorDomain domain, NSInteger error, NSString * errorMessage) {
NSLog(@"domain = %ld, error = %ld, errorMessage = %@", domain, error, errorMessage); // domain = 1, error = 49, errorMessage = Unknown
};
[request start];
總輸出錯誤:domain = 1, error = 49, errorMessage = Unknown
其中,domain=1為:
typedef CF_ENUM(CFIndex, CFStreamErrorDomain) {
kCFStreamErrorDomainCustom = -1L, /* custom to the kind of stream in question */
kCFStreamErrorDomainPOSIX = 1, /* POSIX errno; interpret using <sys/errno.h> */
kCFStreamErrorDomainMacOSStatus /* OSStatus type from Carbon APIs; interpret using <MacTypes.h> */
};
error=49為:#define EADDRNOTAVAIL 49 / Can't assign requested address /
本地待上傳檔案為:@"/var/mobile/Containers/Data/Application/2C632403-AC9C-4250-8E43-0CC0EAC14272/Library/Caches/CrashLog/iPhone_1.0.0.0_udid_201605236376037036370363633003363303633033033件30.
出現這種錯誤是ftp路徑有問題,還是?
ringa_lee