Commit 324c8db8c9e9e83623f8eadf21370370179f8895

Authored by 朱林
1 parent 28a12786

添加上传图片

CNLiveNetworkingDemo/CNLiveNetworking/CNLiveNetworkManager.h
... ... @@ -7,6 +7,7 @@
7 7 //
8 8  
9 9 #import <Foundation/Foundation.h>
  10 +#import <UIKit/UIKit.h>
10 11  
11 12 @interface CNLiveNetworkManager : NSObject
12 13  
... ... @@ -47,5 +48,10 @@
47 48 failure :(nullable void (^)(NSURLResponse *_Nullable response, NSError *_Nullable error))failure;
48 49  
49 50  
  51 +- (void)uploadImageWithURL:(nullable NSString *)URL
  52 + parameters:(nullable NSDictionary *)parameters
  53 + imageData:(nullable NSData *)data
  54 + success:(nullable void (^)(NSURLResponse *_Nullable response, id _Nullable responseObject))success
  55 + failure :(nullable void (^)(NSURLResponse *_Nullable response, NSError *_Nullable error))failure;
50 56  
51 57 @end
... ...
CNLiveNetworkingDemo/CNLiveNetworking/CNLiveNetworkManager.m
... ... @@ -9,11 +9,12 @@
9 9 #import "CNLiveNetworkManager.h"
10 10 #import "CNLiveURLRequestSerialization.h"
11 11  
  12 +#define boundary @"cnlive"
  13 +
12 14 /**
13 15 * 网络超时时间 默认 60
14 16 */
15 17 static NSTimeInterval TimeoutInterval = 30.0 ;
16   -
17 18 /**
18 19 * 缓存策略
19 20 * NSURLRequestUseProtocolCachePolicy // 默认的缓存策略(取决于协议)
... ... @@ -52,7 +53,7 @@ static NSURLRequestCachePolicy CachePolicy = NSURLRequestUseProtocolCachePolicy;
52 53 success:(void (^)(NSURLResponse * _Nullable, id _Nullable))success
53 54 failure:(void (^)(NSURLResponse * _Nullable, NSError * _Nullable))failure
54 55 {
55   - NSURLSessionDataTask *task = [self dataTaskWithRequestMethod:@"GET" URLString:URL parameters:parameters success:success failure:failure];
  56 + NSURLSessionDataTask *task = [self dataTaskWithRequestMethod:@"GET" URLString:URL parameters:parameters imageData:nil success:success failure:failure];
56 57 [task resume];
57 58 }
58 59  
... ... @@ -61,13 +62,20 @@ static NSURLRequestCachePolicy CachePolicy = NSURLRequestUseProtocolCachePolicy;
61 62 success:(void (^)(NSURLResponse * _Nullable, id _Nullable))success
62 63 failure:(void (^)(NSURLResponse * _Nullable, NSError * _Nullable))failure
63 64 {
64   - NSURLSessionDataTask *task = [self dataTaskWithRequestMethod:@"POST" URLString:URL parameters:parameters success:success failure:failure];
  65 + NSURLSessionDataTask *task = [self dataTaskWithRequestMethod:@"POST" URLString:URL parameters:parameters imageData:nil success:success failure:failure];
  66 + [task resume];
  67 +}
  68 +
  69 +- (void)uploadImageWithURL:(NSString *)URL parameters:(NSDictionary *)parameters imageData:(NSData *)data success:(void (^)(NSURLResponse * _Nullable, id _Nullable))success failure:(void (^)(NSURLResponse * _Nullable, NSError * _Nullable))failure
  70 +{
  71 + NSURLSessionDataTask *task = [self dataTaskWithRequestMethod:@"POST" URLString:URL parameters:parameters imageData:data success:success failure:failure];
65 72 [task resume];
66 73 }
67 74  
68 75 - (NSURLSessionDataTask *)dataTaskWithRequestMethod:(NSString *)method
69 76 URLString:(NSString *)URLString
70 77 parameters:(NSDictionary *)parameters
  78 + imageData:(NSData *)data
71 79 success:(void (^)(NSURLResponse * _Nullable, id _Nullable))success
72 80 failure:(void (^)(NSURLResponse * _Nullable, NSError * _Nullable))failure
73 81 {
... ... @@ -94,8 +102,24 @@ static NSURLRequestCachePolicy CachePolicy = NSURLRequestUseProtocolCachePolicy;
94 102 request.HTTPMethod = method;
95 103  
96 104 if([method isEqual:@"POST"]){
97   - [request addValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
98   - request.HTTPBody =[[CNLiveURLRequestSerialization CNQueryStringFromParameters:parameters] dataUsingEncoding:NSUTF8StringEncoding];
  105 + if (!data) {
  106 + [request addValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
  107 + request.HTTPBody =[[CNLiveURLRequestSerialization CNQueryStringFromParameters:parameters] dataUsingEncoding:NSUTF8StringEncoding];
  108 + } else {
  109 + //设置HTTPHeader中Content-Type的值
  110 + NSString *content=[[NSString alloc]initWithFormat:@"multipart/form-data; boundary=%@",boundary];
  111 + //设置HTTPHeader
  112 + [request setValue:content forHTTPHeaderField:@"Content-Type"];
  113 +
  114 + //设置Content-Length
  115 + NSData *requestData = [self setBodyData:data parameters:parameters];
  116 + [request setValue:[NSString stringWithFormat:@"%lu", (unsigned long)[requestData length]] forHTTPHeaderField:@"Content-Length"];
  117 +
  118 + //设置http body
  119 + [request setHTTPBody:requestData];
  120 + [request setHTTPMethod:@"POST"];
  121 +
  122 + }
99 123 }
100 124  
101 125 NSURLSessionDataTask *task = [self dataTaskWithRequest:request success:success failure:failure];
... ... @@ -133,6 +157,53 @@ static NSURLRequestCachePolicy CachePolicy = NSURLRequestUseProtocolCachePolicy;
133 157 return task;
134 158 }
135 159  
  160 +- (NSData *)setBodyData:(NSData *)data parameters:(NSDictionary *)parameters
  161 +{
  162 + //分界线
  163 + NSString *MPBoundary = [[NSString alloc] initWithFormat:@"--%@",boundary];
  164 + //结束符
  165 + NSString *endMPBoundary = [[NSString alloc] initWithFormat:@"%@--",MPBoundary];
  166 +
  167 + NSMutableString *body = [[NSMutableString alloc] init];
  168 +
  169 + if (parameters) {
  170 +
  171 + NSArray *keys = [parameters allKeys];
  172 +
  173 + for (int i = 0; i < [keys count]; i ++) {
  174 + NSString *key = [keys objectAtIndex:i];
  175 +
  176 + //添加分界线,换行
  177 + [body appendFormat:@"%@\r\n",MPBoundary];
  178 +
  179 + //添加字段名称,换2行
  180 + [body appendFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n",key];
  181 + //添加字段的值
  182 + [body appendFormat:@"%@\r\n",[parameters objectForKey:key]];
  183 +
  184 + }
  185 + }
  186 +
  187 + [body appendFormat:@"%@\r\n",MPBoundary];
  188 +
  189 + //声明pic字段,文件名为boris.png
  190 + [body appendFormat:@"Content-Disposition: form-data; name=\"face\"; filename=\"image\"\r\n"];
  191 + //声明上传文件的格式
  192 + [body appendFormat:@"Content-Type: image/jpge,image/gif, image/jpeg, image/pjpeg, image/pjpeg\r\n\r\n"];
  193 +
  194 + //声明结束符:--AaB03x--
  195 + NSString *end=[[NSString alloc]initWithFormat:@"\r\n%@",endMPBoundary];
  196 + //声明myRequestData,用来放入http body
  197 + NSMutableData *myRequestData=[NSMutableData data];
  198 +
  199 + //将body字符串转化为UTF8格式的二进制
  200 + [myRequestData appendData:[body dataUsingEncoding:NSUTF8StringEncoding]];
  201 + [myRequestData appendData:data];
  202 + //加入结束符--AaB03x--
  203 + [myRequestData appendData:[end dataUsingEncoding:NSUTF8StringEncoding]];
  204 + return myRequestData;
  205 +}
  206 +
136 207 - (NSURL *)formatURLString:(NSString *)url
137 208 {
138 209 NSURL *urlString = [NSURL URLWithString:[url stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]];
... ...
CNLiveNetworkingDemo/CNLiveNetworkingDemo.xcodeproj/project.pbxproj
... ... @@ -15,8 +15,8 @@
15 15 1521ED121D4B25ED00798EA8 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1521ED101D4B25ED00798EA8 /* LaunchScreen.storyboard */; };
16 16 1521ED1D1D4B25ED00798EA8 /* CNLiveNetworkingDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1521ED1C1D4B25ED00798EA8 /* CNLiveNetworkingDemoTests.m */; };
17 17 1521ED281D4B25ED00798EA8 /* CNLiveNetworkingDemoUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1521ED271D4B25ED00798EA8 /* CNLiveNetworkingDemoUITests.m */; };
18   - 1521ED3A1D4B261C00798EA8 /* CNLiveNetworkManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 1521ED371D4B261C00798EA8 /* CNLiveNetworkManager.m */; };
19   - 1521ED3B1D4B261C00798EA8 /* CNLiveURLRequestSerialization.m in Sources */ = {isa = PBXBuildFile; fileRef = 1521ED391D4B261C00798EA8 /* CNLiveURLRequestSerialization.m */; };
  18 + 815611BF1D9378CA00918299 /* CNLiveNetworkManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 815611BC1D9378CA00918299 /* CNLiveNetworkManager.m */; };
  19 + 815611C01D9378CA00918299 /* CNLiveURLRequestSerialization.m in Sources */ = {isa = PBXBuildFile; fileRef = 815611BE1D9378CA00918299 /* CNLiveURLRequestSerialization.m */; };
20 20 /* End PBXBuildFile section */
21 21  
22 22 /* Begin PBXContainerItemProxy section */
... ... @@ -53,10 +53,10 @@
53 53 1521ED231D4B25ED00798EA8 /* CNLiveNetworkingDemoUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CNLiveNetworkingDemoUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
54 54 1521ED271D4B25ED00798EA8 /* CNLiveNetworkingDemoUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CNLiveNetworkingDemoUITests.m; sourceTree = "<group>"; };
55 55 1521ED291D4B25ED00798EA8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
56   - 1521ED361D4B261C00798EA8 /* CNLiveNetworkManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CNLiveNetworkManager.h; sourceTree = "<group>"; };
57   - 1521ED371D4B261C00798EA8 /* CNLiveNetworkManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CNLiveNetworkManager.m; sourceTree = "<group>"; };
58   - 1521ED381D4B261C00798EA8 /* CNLiveURLRequestSerialization.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CNLiveURLRequestSerialization.h; sourceTree = "<group>"; };
59   - 1521ED391D4B261C00798EA8 /* CNLiveURLRequestSerialization.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CNLiveURLRequestSerialization.m; sourceTree = "<group>"; };
  56 + 815611BB1D9378CA00918299 /* CNLiveNetworkManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CNLiveNetworkManager.h; sourceTree = "<group>"; };
  57 + 815611BC1D9378CA00918299 /* CNLiveNetworkManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CNLiveNetworkManager.m; sourceTree = "<group>"; };
  58 + 815611BD1D9378CA00918299 /* CNLiveURLRequestSerialization.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CNLiveURLRequestSerialization.h; sourceTree = "<group>"; };
  59 + 815611BE1D9378CA00918299 /* CNLiveURLRequestSerialization.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CNLiveURLRequestSerialization.m; sourceTree = "<group>"; };
60 60 /* End PBXFileReference section */
61 61  
62 62 /* Begin PBXFrameworksBuildPhase section */
... ... @@ -87,7 +87,7 @@
87 87 1521ECF61D4B25ED00798EA8 = {
88 88 isa = PBXGroup;
89 89 children = (
90   - 1521ED351D4B261C00798EA8 /* CNLiveNetworking */,
  90 + 815611BA1D9378CA00918299 /* CNLiveNetworking */,
91 91 1521ED011D4B25ED00798EA8 /* CNLiveNetworkingDemo */,
92 92 1521ED1B1D4B25ED00798EA8 /* CNLiveNetworkingDemoTests */,
93 93 1521ED261D4B25ED00798EA8 /* CNLiveNetworkingDemoUITests */,
... ... @@ -147,13 +147,13 @@
147 147 path = CNLiveNetworkingDemoUITests;
148 148 sourceTree = "<group>";
149 149 };
150   - 1521ED351D4B261C00798EA8 /* CNLiveNetworking */ = {
  150 + 815611BA1D9378CA00918299 /* CNLiveNetworking */ = {
151 151 isa = PBXGroup;
152 152 children = (
153   - 1521ED361D4B261C00798EA8 /* CNLiveNetworkManager.h */,
154   - 1521ED371D4B261C00798EA8 /* CNLiveNetworkManager.m */,
155   - 1521ED381D4B261C00798EA8 /* CNLiveURLRequestSerialization.h */,
156   - 1521ED391D4B261C00798EA8 /* CNLiveURLRequestSerialization.m */,
  153 + 815611BB1D9378CA00918299 /* CNLiveNetworkManager.h */,
  154 + 815611BC1D9378CA00918299 /* CNLiveNetworkManager.m */,
  155 + 815611BD1D9378CA00918299 /* CNLiveURLRequestSerialization.h */,
  156 + 815611BE1D9378CA00918299 /* CNLiveURLRequestSerialization.m */,
157 157 );
158 158 path = CNLiveNetworking;
159 159 sourceTree = "<group>";
... ... @@ -289,10 +289,10 @@
289 289 buildActionMask = 2147483647;
290 290 files = (
291 291 1521ED0A1D4B25ED00798EA8 /* ViewController.m in Sources */,
292   - 1521ED3B1D4B261C00798EA8 /* CNLiveURLRequestSerialization.m in Sources */,
  292 + 815611C01D9378CA00918299 /* CNLiveURLRequestSerialization.m in Sources */,
293 293 1521ED071D4B25ED00798EA8 /* AppDelegate.m in Sources */,
294 294 1521ED041D4B25ED00798EA8 /* main.m in Sources */,
295   - 1521ED3A1D4B261C00798EA8 /* CNLiveNetworkManager.m in Sources */,
  295 + 815611BF1D9378CA00918299 /* CNLiveNetworkManager.m in Sources */,
296 296 );
297 297 runOnlyForDeploymentPostprocessing = 0;
298 298 };
... ... @@ -518,6 +518,7 @@
518 518 1521ED2E1D4B25ED00798EA8 /* Release */,
519 519 );
520 520 defaultConfigurationIsVisible = 0;
  521 + defaultConfigurationName = Release;
521 522 };
522 523 1521ED2F1D4B25ED00798EA8 /* Build configuration list for PBXNativeTarget "CNLiveNetworkingDemoTests" */ = {
523 524 isa = XCConfigurationList;
... ... @@ -526,6 +527,7 @@
526 527 1521ED311D4B25ED00798EA8 /* Release */,
527 528 );
528 529 defaultConfigurationIsVisible = 0;
  530 + defaultConfigurationName = Release;
529 531 };
530 532 1521ED321D4B25ED00798EA8 /* Build configuration list for PBXNativeTarget "CNLiveNetworkingDemoUITests" */ = {
531 533 isa = XCConfigurationList;
... ... @@ -534,6 +536,7 @@
534 536 1521ED341D4B25ED00798EA8 /* Release */,
535 537 );
536 538 defaultConfigurationIsVisible = 0;
  539 + defaultConfigurationName = Release;
537 540 };
538 541 /* End XCConfigurationList section */
539 542 };
... ...
CNLiveNetworkingDemo/CNLiveNetworkingDemo.xcodeproj/project.xcworkspace/xcuserdata/android.xcuserdatad/UserInterfaceState.xcuserstate
No preview for this file type
CNLiveNetworkingDemo/CNLiveNetworkingDemo.xcodeproj/project.xcworkspace/xcuserdata/iOS.xcuserdatad/UserInterfaceState.xcuserstate 0 → 100644
No preview for this file type
CNLiveNetworkingDemo/CNLiveNetworkingDemo.xcodeproj/xcuserdata/iOS.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<Bucket
  3 + type = "1"
  4 + version = "2.0">
  5 + <Breakpoints>
  6 + <BreakpointProxy
  7 + BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
  8 + <BreakpointContent
  9 + shouldBeEnabled = "No"
  10 + ignoreCount = "0"
  11 + continueAfterRunningActions = "No"
  12 + filePath = "CNLiveNetworkingDemo/ViewController.m"
  13 + timestampString = "495358640.474018"
  14 + startingColumnNumber = "9223372036854775807"
  15 + endingColumnNumber = "9223372036854775807"
  16 + startingLineNumber = "92"
  17 + endingLineNumber = "92"
  18 + landmarkName = "-touchesBegan:withEvent:"
  19 + landmarkType = "5">
  20 + </BreakpointContent>
  21 + </BreakpointProxy>
  22 + </Breakpoints>
  23 +</Bucket>
... ...
CNLiveNetworkingDemo/CNLiveNetworkingDemo.xcodeproj/xcuserdata/iOS.xcuserdatad/xcschemes/CNLiveNetworkingDemo.xcscheme 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<Scheme
  3 + LastUpgradeVersion = "0730"
  4 + version = "1.3">
  5 + <BuildAction
  6 + parallelizeBuildables = "YES"
  7 + buildImplicitDependencies = "YES">
  8 + <BuildActionEntries>
  9 + <BuildActionEntry
  10 + buildForTesting = "YES"
  11 + buildForRunning = "YES"
  12 + buildForProfiling = "YES"
  13 + buildForArchiving = "YES"
  14 + buildForAnalyzing = "YES">
  15 + <BuildableReference
  16 + BuildableIdentifier = "primary"
  17 + BlueprintIdentifier = "1521ECFE1D4B25ED00798EA8"
  18 + BuildableName = "CNLiveNetworkingDemo.app"
  19 + BlueprintName = "CNLiveNetworkingDemo"
  20 + ReferencedContainer = "container:CNLiveNetworkingDemo.xcodeproj">
  21 + </BuildableReference>
  22 + </BuildActionEntry>
  23 + </BuildActionEntries>
  24 + </BuildAction>
  25 + <TestAction
  26 + buildConfiguration = "Debug"
  27 + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
  28 + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
  29 + shouldUseLaunchSchemeArgsEnv = "YES">
  30 + <Testables>
  31 + <TestableReference
  32 + skipped = "NO">
  33 + <BuildableReference
  34 + BuildableIdentifier = "primary"
  35 + BlueprintIdentifier = "1521ED171D4B25ED00798EA8"
  36 + BuildableName = "CNLiveNetworkingDemoTests.xctest"
  37 + BlueprintName = "CNLiveNetworkingDemoTests"
  38 + ReferencedContainer = "container:CNLiveNetworkingDemo.xcodeproj">
  39 + </BuildableReference>
  40 + </TestableReference>
  41 + <TestableReference
  42 + skipped = "NO">
  43 + <BuildableReference
  44 + BuildableIdentifier = "primary"
  45 + BlueprintIdentifier = "1521ED221D4B25ED00798EA8"
  46 + BuildableName = "CNLiveNetworkingDemoUITests.xctest"
  47 + BlueprintName = "CNLiveNetworkingDemoUITests"
  48 + ReferencedContainer = "container:CNLiveNetworkingDemo.xcodeproj">
  49 + </BuildableReference>
  50 + </TestableReference>
  51 + </Testables>
  52 + <MacroExpansion>
  53 + <BuildableReference
  54 + BuildableIdentifier = "primary"
  55 + BlueprintIdentifier = "1521ECFE1D4B25ED00798EA8"
  56 + BuildableName = "CNLiveNetworkingDemo.app"
  57 + BlueprintName = "CNLiveNetworkingDemo"
  58 + ReferencedContainer = "container:CNLiveNetworkingDemo.xcodeproj">
  59 + </BuildableReference>
  60 + </MacroExpansion>
  61 + <AdditionalOptions>
  62 + </AdditionalOptions>
  63 + </TestAction>
  64 + <LaunchAction
  65 + buildConfiguration = "Debug"
  66 + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
  67 + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
  68 + launchStyle = "0"
  69 + useCustomWorkingDirectory = "NO"
  70 + ignoresPersistentStateOnLaunch = "NO"
  71 + debugDocumentVersioning = "YES"
  72 + debugServiceExtension = "internal"
  73 + allowLocationSimulation = "YES">
  74 + <BuildableProductRunnable
  75 + runnableDebuggingMode = "0">
  76 + <BuildableReference
  77 + BuildableIdentifier = "primary"
  78 + BlueprintIdentifier = "1521ECFE1D4B25ED00798EA8"
  79 + BuildableName = "CNLiveNetworkingDemo.app"
  80 + BlueprintName = "CNLiveNetworkingDemo"
  81 + ReferencedContainer = "container:CNLiveNetworkingDemo.xcodeproj">
  82 + </BuildableReference>
  83 + </BuildableProductRunnable>
  84 + <AdditionalOptions>
  85 + </AdditionalOptions>
  86 + </LaunchAction>
  87 + <ProfileAction
  88 + buildConfiguration = "Release"
  89 + shouldUseLaunchSchemeArgsEnv = "YES"
  90 + savedToolIdentifier = ""
  91 + useCustomWorkingDirectory = "NO"
  92 + debugDocumentVersioning = "YES">
  93 + <BuildableProductRunnable
  94 + runnableDebuggingMode = "0">
  95 + <BuildableReference
  96 + BuildableIdentifier = "primary"
  97 + BlueprintIdentifier = "1521ECFE1D4B25ED00798EA8"
  98 + BuildableName = "CNLiveNetworkingDemo.app"
  99 + BlueprintName = "CNLiveNetworkingDemo"
  100 + ReferencedContainer = "container:CNLiveNetworkingDemo.xcodeproj">
  101 + </BuildableReference>
  102 + </BuildableProductRunnable>
  103 + </ProfileAction>
  104 + <AnalyzeAction
  105 + buildConfiguration = "Debug">
  106 + </AnalyzeAction>
  107 + <ArchiveAction
  108 + buildConfiguration = "Release"
  109 + revealArchiveInOrganizer = "YES">
  110 + </ArchiveAction>
  111 +</Scheme>
... ...
CNLiveNetworkingDemo/CNLiveNetworkingDemo.xcodeproj/xcuserdata/iOS.xcuserdatad/xcschemes/xcschememanagement.plist 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  3 +<plist version="1.0">
  4 +<dict>
  5 + <key>SchemeUserState</key>
  6 + <dict>
  7 + <key>CNLiveNetworkingDemo.xcscheme</key>
  8 + <dict>
  9 + <key>orderHint</key>
  10 + <integer>0</integer>
  11 + </dict>
  12 + </dict>
  13 + <key>SuppressBuildableAutocreation</key>
  14 + <dict>
  15 + <key>1521ECFE1D4B25ED00798EA8</key>
  16 + <dict>
  17 + <key>primary</key>
  18 + <true/>
  19 + </dict>
  20 + <key>1521ED171D4B25ED00798EA8</key>
  21 + <dict>
  22 + <key>primary</key>
  23 + <true/>
  24 + </dict>
  25 + <key>1521ED221D4B25ED00798EA8</key>
  26 + <dict>
  27 + <key>primary</key>
  28 + <true/>
  29 + </dict>
  30 + </dict>
  31 +</dict>
  32 +</plist>
... ...
CNLiveNetworkingDemo/CNLiveNetworkingDemo/Assets.xcassets/AppIcon.appiconset/Contents.json
... ... @@ -59,6 +59,11 @@
59 59 "idiom" : "ipad",
60 60 "size" : "76x76",
61 61 "scale" : "2x"
  62 + },
  63 + {
  64 + "idiom" : "ipad",
  65 + "size" : "83.5x83.5",
  66 + "scale" : "2x"
62 67 }
63 68 ],
64 69 "info" : {
... ...
CNLiveNetworkingDemo/CNLiveNetworkingDemo/Assets.xcassets/Contents.json 0 → 100644
  1 +{
  2 + "info" : {
  3 + "version" : 1,
  4 + "author" : "xcode"
  5 + }
  6 +}
0 7 \ No newline at end of file
... ...
CNLiveNetworkingDemo/CNLiveNetworkingDemo/Assets.xcassets/弹off.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "filename" : "弹off.png",
  6 + "scale" : "1x"
  7 + },
  8 + {
  9 + "idiom" : "universal",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "idiom" : "universal",
  14 + "scale" : "3x"
  15 + }
  16 + ],
  17 + "info" : {
  18 + "version" : 1,
  19 + "author" : "xcode"
  20 + }
  21 +}
0 22 \ No newline at end of file
... ...
CNLiveNetworkingDemo/CNLiveNetworkingDemo/Assets.xcassets/弹off.imageset/弹off.png 0 → 100644

1.49 KB

CNLiveNetworkingDemo/CNLiveNetworkingDemo/ViewController.m
... ... @@ -86,7 +86,14 @@
86 86  
87 87 - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
88 88 {
89   - [self.view endEditing:YES];
  89 +// [self.view endEditing:YES];
  90 + [[CNLiveNetworkManager manager] uploadImageWithURL:@"http://120.25.226.186:32812/upload" parameters:nil image:[UIImage imageNamed:@"弹off"] success:^(NSURLResponse * _Nullable response, id _Nullable responseObject) {
  91 + NSLog(@"get==success==%@",responseObject);
  92 + _text.text = [NSString stringWithFormat:@"%@",responseObject];
  93 + } failure:^(NSURLResponse * _Nullable response, NSError * _Nullable error) {
  94 + NSLog(@"get==failure==%@",error.localizedDescription);
  95 + _text.text = [NSString stringWithFormat:@"%@",error.localizedDescription];
  96 + }];
90 97 }
91 98  
92 99 - (void)didReceiveMemoryWarning {
... ...