//
//  HSNSURLSession.h
//  HSDownloadManagerExample
//
//  Created by hans on 15/8/4.
//  Copyright © 2015年 hans. All rights reserved.
//
#import <UIKit/UIKit.h>
#warning 抛出401错误时重新获取url.
/**
 待进一步完善(分段下载,range->byte:A-B)
 */
typedef void (^DownloadProgressBlock)(NSInteger receivedSize, NSInteger expectedSize, CGFloat progress,NSString *router,NSString *msgUUID);

typedef void (^DownloadSuccessBlock)(NSInteger receivedSize, NSString *localFullFileRouter,NSString *msgUUID);
typedef void (^DownloadFailedBlock)(NSString* errMessage,NSString *msgUUID);


@interface WSDownloadSession : NSObject


/**
 *  for db->move to last page.
 */
//@property (nonatomic , strong) DownloadProgressBlock downloadProgressDBBlock;
//
//@property (nonatomic , strong) DownloadSuccessBlock downloadSuccessDBBlock;
//
//@property (nonatomic , strong) DownloadFailedBlock downloadFailedDBBlock;


/**
 *  for ui
 */
@property (nonatomic , strong) DownloadProgressBlock downloadProgressBlock;

@property (nonatomic , strong) DownloadSuccessBlock downloadSuccessBlock;

@property (nonatomic , strong) DownloadFailedBlock downloadFailedBlock;

//local path为文件的前一个文件夹, 比如 cloudstorage/A/文件. 如果没有则直接放在cloudstorage上,否则创建某个文件夹,再放入文件.
+ (id)oneDownloadSessionWithFileUrlString:(NSString *)downloadUrl savePath:(NSString *)path localPath:(NSString *)localPath fileMd5:(NSString *)md5 UUID:(NSString *)uuid fileName:(NSString *)fileName downloadedSize:(NSInteger)downloadedSize fileSize:(NSInteger)fileSize progressblock:(DownloadProgressBlock)progressBlock successblock:(DownloadSuccessBlock)successblock failedBlock:(DownloadFailedBlock)failedBlock;


- (void)cancer;

@end
