iOS ftp上传文件图片等资源方法

来源:互联网 发布:js数组删除元素的代码 编辑:程序博客网 时间:2024/05/22 15:14

具体方法下载Github:https://github.com/humengchi/FTP

部分代码如下:

+ (instancetype)shareInstance {    static FTPMonitorInstance *instance = nil;    static dispatch_once_t onceToken;    dispatch_once(&onceToken, ^{        instance = [[FTPMonitorInstance alloc] init];    });        return instance;}- (void)configFTPMonitorWithUserModel:(UserModel *)userModel {    self.manager = [[FTPManager alloc] init];    NSString *host = @"192.168.1.1";    FMServer *server =  [FMServer serverWithDestination:host username:FTP_ACCOUNT password:FTP_PASSWORD];        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{        // 创建ftp client目录        NSString *folder = [NSString stringWithFormat:@"%d",101];        BOOL isSuccess = [self.manager createNewFolder:folder atServer:server];        DDLogInfo(@"---创建ftp client目录 %@---",isSuccess ? @"成功":@"失败");                // 创建ftp clientUser目录        folder = [NSString stringWithFormat:@"%@/%d",folder,                  [DataModelInstance shareInstance].userModel.client_user_id.intValue];        isSuccess = [self.manager createNewFolder:folder atServer:server];        DDLogInfo(@"---创建ftp clientUser目录 %@---",isSuccess ? @"成功":@"失败");                // 创建ftp 根目录        NSString *rootfolder = @"bn";        isSuccess = [self.manager createNewFolder:rootfolder atServer:server];        DDLogInfo(@"---创建ftp 根目录 %@---",isSuccess ? @"成功":@"失败");                // 创建ftp client目录        storeDoorfolder = [NSString stringWithFormat:@"%@/%d",rootfolder,101];        isSuccess = [self.manager createNewFolder:storeDoorfolder atServer:server];        DDLogInfo(@"---创建ftp client目录 %@---",isSuccess ? @"成功":@"失败");    });        // 全局变量设定    NSString *url = [NSString stringWithFormat:@"%@:%@/%d/%d", host, FTP_PORT,                     [DataModelInstance shareInstance].userModel.client_id.intValue,                     [DataModelInstance shareInstance].userModel.client_user_id.intValue                     ];    self.server = [FMServer serverWithDestination:url username:FTP_ACCOUNT password:FTP_PASSWORD];}


0 0