1.网络请求的实例方法
/**
*网络请求的实例方法
*
*@param typeget / post
*@param urlString请求的地址
*@param paraments请求的参数
*@param successBlock请求成功的回调
*@param failureBlock请求失败的回调
*@param progress进度
*/
+(void)requestWithType:(HttpRequestType)type withUrlString:(NSString*)urlString withParaments:(id)paraments withSuccessBlock:(requestSuccess)successBlock withFailureBlock:(requestFailure)failureBlock progress:(downloadProgress)progress;
2.上传图片(包含多张上传)
/**
*上传图片
*
*@param operations上传图片预留参数---视具体情况而定可移除
*@param imageArray上传的图片数组
*@parm width图片要被压缩到的宽度
*@param urlString上传的url
*@param successBlock上传成功的回调
*@param failureBlock上传失败的回调
*@param progress上传进度
*/
+(void)uploadImageWithOperations:(NSDictionary*)operations withImageArray:(NSArray*)imageArray withtargetWidth:(CGFloat)width withUrlString:(NSString*)urlString withSuccessBlock:(requestSuccess)successBlock withFailurBlock:(requestFailure)failureBlock withUpLoadProgress:(uploadProgress)progress;
3.视频上传
/**
*视频上传
*
*@param operations上传视频预留参数---视具体情况而定可移除
*@param videoPath上传视频的本地沙河路径
*@param urlString上传的url
*@param successBlock成功的回调
*@param failureBlock失败的回调
*@param progress上传的进度
*/
+(void)uploadVideoWithOperaitons:(NSDictionary*)operations withVideoPath:(NSString*)videoPath withUrlString:(NSString*)urlString withSuccessBlock:(requestSuccess)successBlock withFailureBlock:(requestFailure)failureBlock withUploadProgress:(uploadProgress)progress;
4.文件下载(如音频文件)
/**
*文件下载
*
*@param operations文件下载预留参数---视具体情况而定可移除
*@param savePath下载文件保存路径
*@param urlString请求的url
*@param successBlock下载文件成功的回调
*@param failureBlock下载文件失败的回调
*@param progress下载文件的进度显示
*/
+(void)downLoadFileWithOperations:(NSDictionary*)operations withSavaPath:(NSString*)savePath withUrlString:(NSString*)urlString withSuccessBlock:(requestSuccess)successBlock withFailureBlock:(requestFailure)failureBlock withDownLoadProgress:(downloadProgress)progress;
5.取消所有的网络请求
/**
*取消所有的网络请求
*/
+(void)cancelAllRequest;
6.取消指定网络
/**
*取消指定的url请求
*
*@param requestType该请求的请求类型
*@param string该请求的url
*/
+(void)cancelHttpRequestWithRequestType:(NSString*)requestType requestUrlString:(NSString*)string;
demo地址
基于AFNetworking 3.0的集约性网络请求API再封装 支持多图压缩上传,视频,音频上传,文件下载等功能
(https://github.com/SummerHF/AFNetworking-)
本文转载于作者:CharlesAir
相关文章:五阿哥永琪