Skip to content

Commit

Permalink
1.修改添加上传策略,签名不通过的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
aplaycat committed Dec 11, 2017
1 parent 8d9dd99 commit 549a0a0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions ucloud-ufile-sdk/OC/UFileSDK/Classes/UFileAPI.m
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ - (NSURLSessionDataTask * _Nullable ) putFile:(NSString*)fileName
body:data
progress:uploadProgress
success:^(NSURLSessionDataTask * task, id responseObject) {

NSHTTPURLResponse* resp = (NSHTTPURLResponse*)task.response;
NSError * error = [[self class] _checkHttpRespError:resp body:responseObject];
if (error) {
Expand Down Expand Up @@ -507,8 +508,8 @@ + (NSError*) _checkHttpRespError:(NSHTTPURLResponse*)response body:(NSData*)body
} else {
userInfo = @{
kUFileRespHttpStatusCode: [NSNumber numberWithLong:response.statusCode],
kUFileRespErrMsg: respObj[kUFileRespErrMsg],
kUFileRespXSession: response.allHeaderFields[@"X-SessionId"]
kUFileRespErrMsg: respObj[kUFileRespErrMsg]
// ,kUFileRespXSession: response.allHeaderFields[@"X-SessionId"]
};
retCode = [respObj[kUFileRespRetCode] integerValue];
}
Expand Down
5 changes: 4 additions & 1 deletion ucloud-ufile-sdk/OC/UFileSDK/UFileSDK.mm
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ -(NSString*)calcKey:(NSString*)httpMethod Key:(NSString*)key MD5:(NSString*)co
if (policy) {
NSError *error = nil;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:policy options:NSJSONWritingPrettyPrinted error:&error];
NSString* policy = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
if (!error && jsonData) {
self.callBackPolicy = [self stringFromResult: (void*)jsonData.bytes Len:jsonData.length];
self.callBackPolicy = [self stringFromResult: (void*)policy.UTF8String Len:policy.length];
}
strBody = [NSString stringWithFormat:@"%@%@",strBody,self.callBackPolicy];
}
return [self _sha1Sum: self.privateKey withString:strBody];

Expand Down Expand Up @@ -80,4 +82,5 @@ -(NSString*)stringFromResult:(void*)result Len:(NSInteger)length
return [data base64EncodedStringWithOptions:0];
}


@end

0 comments on commit 549a0a0

Please sign in to comment.