1.網(wǎng)絡(luò)請求的實例方法
/**
*網(wǎng)絡(luò)請求的實例方法
*
*@param typeget / post
*@param urlString請求的地址
*@param paraments請求的參數(shù)
*@param successBlock請求成功的回調(diào)
*@param failureBlock請求失敗的回調(diào)
*@param progress進度
*/
+(void)requestWithType:(HttpRequestType)type withUrlString:(NSString*)urlString withParaments:(id)paraments withSuccessBlock:(requestSuccess)successBlock withFailureBlock:(requestFailure)failureBlock progress:(downloadProgress)progress;
2.上傳圖片(包含多張上傳)
/**
*上傳圖片
*
*@param operations上傳圖片預(yù)留參數(shù)---視具體情況而定可移除
*@param imageArray上傳的圖片數(shù)組
*@parm width圖片要被壓縮到的寬度
*@param urlString上傳的url
*@param successBlock上傳成功的回調(diào)
*@param failureBlock上傳失敗的回調(diào)
*@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上傳視頻預(yù)留參數(shù)---視具體情況而定可移除
*@param videoPath上傳視頻的本地沙河路徑
*@param urlString上傳的url
*@param successBlock成功的回調(diào)
*@param failureBlock失敗的回調(diào)
*@param progress上傳的進度
*/
+(void)uploadVideoWithOperaitons:(NSDictionary*)operations withVideoPath:(NSString*)videoPath withUrlString:(NSString*)urlString withSuccessBlock:(requestSuccess)successBlock withFailureBlock:(requestFailure)failureBlock withUploadProgress:(uploadProgress)progress;
4.文件下載(如音頻文件)
/**
*文件下載
*
*@param operations文件下載預(yù)留參數(shù)---視具體情況而定可移除
*@param savePath下載文件保存路徑
*@param urlString請求的url
*@param successBlock下載文件成功的回調(diào)
*@param failureBlock下載文件失敗的回調(diào)
*@param progress下載文件的進度顯示
*/
+(void)downLoadFileWithOperations:(NSDictionary*)operations withSavaPath:(NSString*)savePath withUrlString:(NSString*)urlString withSuccessBlock:(requestSuccess)successBlock withFailureBlock:(requestFailure)failureBlock withDownLoadProgress:(downloadProgress)progress;
5.取消所有的網(wǎng)絡(luò)請求
/**
*取消所有的網(wǎng)絡(luò)請求
*/
+(void)cancelAllRequest;
6.取消指定網(wǎng)絡(luò)
/**
*取消指定的url請求
*
*@param requestType該請求的請求類型
*@param string該請求的url
*/
+(void)cancelHttpRequestWithRequestType:(NSString*)requestType requestUrlString:(NSString*)string;
demo地址
基于AFNetworking 3.0的集約性網(wǎng)絡(luò)請求API再封裝 支持多圖壓縮上傳,視頻,音頻上傳,文件下載等功能
(https://github.com/SummerHF/AFNetworking-)
本文轉(zhuǎn)載于作者:CharlesAir
相關(guān)文章:五阿哥永琪