@@ -25,6 +25,7 @@ @interface QNFormUpload ()
2525@property (nonatomic , strong ) QNUploadOption *option;
2626@property (nonatomic , strong ) QNUpCompletionHandler complete;
2727@property (nonatomic , strong ) QNConfiguration *config;
28+ @property (nonatomic , strong ) NSString *fileName;
2829@property (nonatomic ) float previousPercent;
2930
3031@property (nonatomic , strong ) NSString *access; // AK
@@ -35,6 +36,7 @@ @implementation QNFormUpload
3536
3637- (instancetype )initWithData : (NSData *)data
3738 withKey : (NSString *)key
39+ withFileName : (NSString *)fileName
3840 withToken : (QNUpToken *)token
3941 withCompletionHandler : (QNUpCompletionHandler)block
4042 withOption : (QNUploadOption *)option
@@ -48,6 +50,7 @@ - (instancetype)initWithData:(NSData *)data
4850 _complete = block;
4951 _httpManager = http;
5052 _config = config;
53+ _fileName = fileName != nil ? fileName : @" ?" ;
5154 _previousPercent = 0 ;
5255 _access = token.access ;
5356 }
@@ -56,11 +59,8 @@ - (instancetype)initWithData:(NSData *)data
5659
5760- (void )put {
5861 NSMutableDictionary *parameters = [NSMutableDictionary dictionary ];
59- NSString *fileName = _key;
6062 if (_key) {
6163 parameters[@" key" ] = _key;
62- } else {
63- fileName = @" ?" ;
6464 }
6565 parameters[@" token" ] = _token.token ;
6666 [parameters addEntriesFromDictionary: _option.params];
@@ -119,7 +119,7 @@ - (void)put {
119119 [_httpManager multipartPost: thirdHost
120120 withData: _data
121121 withParams: parameters
122- withFileName: fileName
122+ withFileName: _fileName
123123 withMimeType: _option.mimeType
124124 withCompleteBlock: thirdComplete
125125 withProgressBlock: p
@@ -129,7 +129,7 @@ - (void)put {
129129 [_httpManager multipartPost: nextHost
130130 withData: _data
131131 withParams: parameters
132- withFileName: fileName
132+ withFileName: _fileName
133133 withMimeType: _option.mimeType
134134 withCompleteBlock: retriedComplete
135135 withProgressBlock: p
@@ -139,7 +139,7 @@ - (void)put {
139139 [_httpManager multipartPost: upHost
140140 withData: _data
141141 withParams: parameters
142- withFileName: fileName
142+ withFileName: _fileName
143143 withMimeType: _option.mimeType
144144 withCompleteBlock: complete
145145 withProgressBlock: p
0 commit comments