-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathCoding_FileManager.h
executable file
·84 lines (67 loc) · 3.16 KB
/
Coding_FileManager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//
// Coding_FileManager.h
// Coding_iOS
//
// Created by Ease on 14/11/18.
// Copyright (c) 2014年 Coding. All rights reserved.
//
#define kNotificationUploadCompled @"notification_upload_compled"
//{NSURLResponse: response, NSError: error, ProjectFile: data}
#import <Foundation/Foundation.h>
#import "AFNetworking.h"
#import "DirectoryWatcher.h"
#import "ProjectFile.h"
#import "FileVersion.h"
@class Coding_DownloadTask;
@class Coding_UploadTask;
@class ProjectFile;
@class Coding_UploadParams;
@protocol Coding_FileManagerDelegate;
@interface Coding_FileManager : NSObject
//download
+ (Coding_FileManager *)sharedManager;
+ (AFURLSessionManager *)af_manager;
- (AFURLSessionManager *)af_manager;
- (NSURL *)urlForDownloadFolder;
+ (NSArray *)localFileUrlList;
+(NSURL *)diskDownloadUrlForKey:(NSString *)storage_key;
+ (Coding_DownloadTask *)cDownloadTaskForKey:(NSString *)storage_key;
+ (void)cancelCDownloadTaskForKey:(NSString *)storage_key;
+ (Coding_DownloadTask *)cDownloadTaskForResponse:(NSURLResponse *)response;
+ (void)cancelCDownloadTaskForResponse:(NSURLResponse *)response;
- (Coding_DownloadTask *)addDownloadTaskForObj:(id)obj completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler;
//upload
+ (BOOL)writeUploadDataWithName:(NSString *)fileName andAsset:(PHAsset *)asset;
+ (BOOL)writeUploadDataWithName:(NSString *)fileName andImage:(UIImage *)image;
+ (BOOL)deleteUploadDataWithName:(NSString *)fileName;
+ (NSURL *)diskUploadUrlForFile:(NSString *)diskFileName;
+ (Coding_UploadTask *)cUploadTaskForFile:(NSString *)diskFileName;
+ (void)cancelCUploadTaskForFile:(NSString *)diskFileName hasError:(BOOL)hasError;
+ (NSArray *)uploadFilesInProject:(NSString *)project_id andFolder:(NSString *)folder_id;
- (void)addUploadTaskWithFileName:(NSString *)fileName isQuick:(BOOL)isQuick resultBlock:(void (^)(Coding_UploadTask *uploadTask))block;
- (Coding_UploadTask *)addUploadTaskWithFileName:(NSString *)fileName projectIsPublic:(BOOL)is_public;
@end
@interface Coding_DownloadTask : NSObject
@property (strong, nonatomic) NSURLSessionDownloadTask *task;
@property (strong, nonatomic) NSProgress *progress;
@property (strong, nonatomic) NSString *diskFileName;
+ (Coding_DownloadTask *)cDownloadTaskWithTask:(NSURLSessionDownloadTask *)task progress:(NSProgress *)progress fileName:(NSString *)fileName;
- (void)cancel;
@end
@interface Coding_UploadTask : NSObject
@property (strong, nonatomic) NSURLSessionUploadTask *task;
@property (strong, nonatomic) NSProgress *progress;
@property (strong, nonatomic) NSString *fileName;
+ (Coding_UploadTask *)cUploadTaskWithTask:(NSURLSessionUploadTask *)task progress:(NSProgress *)progress fileName:(NSString *)fileName;
- (void)cancel;
@end
@interface Coding_UploadParams : NSObject
@property (strong, nonatomic) NSString *fileName, *authToken, *time, *uptoken, *fullName;
@property (strong, nonatomic) NSNumber *projectId, *fileSize, *userId, *dir;
@property (assign, nonatomic) BOOL isQuick;
+ (instancetype)instanceWithFileName:(NSString *)fileName;
- (void)configWithFileName:(NSString *)fileName;
- (NSDictionary *)toTokenParams;
- (NSURL *)filePathUrl;
- (NSDictionary *)toUploadParams;
@end