Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions AliyunOSSSDK/OSSClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -1758,9 +1758,8 @@ - (OSSTask *)sequentialUpload:(OSSMultipartUploadRequest *)request
realPartLength = uploadFileSize - request.partSize * (i - 1);
#pragma clang diagnostic pop
}
NSData *uploadPartData = [fileHande readDataOfLength:realPartLength];

@autoreleasepool {
NSData *uploadPartData = [fileHande readDataOfLength:realPartLength];
OSSUploadPartRequest * uploadPart = [OSSUploadPartRequest new];
uploadPart.bucketName = request.bucketName;
uploadPart.objectkey = request.objectKey;
Expand Down
4 changes: 4 additions & 0 deletions AliyunOSSSDK/OSSModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@ Sets the session Id for background file transmission
是否开启crc校验(当同时设置了此选项和请求中的checkCRC开关时,以请求中的checkCRC开关为准)
*/
@property (nonatomic, assign) BOOL crc64Verifiable;
/*
ip访问需要添加参数ipWithHeader
*/
@property (nonatomic, copy) NSString * ipWithHeader;

@end

Expand Down
18 changes: 17 additions & 1 deletion AliyunOSSSDK/OSSModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,25 @@ - (instancetype)initWithClientConfiguration:(OSSClientConfiguration *)clientConf
- (OSSTask *)interceptRequestMessage:(OSSAllRequestNeededMessage *)request {
NSString * userAgent = [self getUserAgent:self.clientConfiguration.userAgentMark];
[request.headerParams oss_setObject:userAgent forKey:@"User-Agent"];
if ([self isIPAddress:request.endpoint]) {
[request.headerParams oss_setObject:self.clientConfiguration.ipWithHeader forKey:@"host"];
}
return [OSSTask taskWithResult:nil];
}

/**
* 判断字符串是否为IP地址
* param iPAddress IP地址字符串
* return BOOL 是返回YES,否返回NO
*/
- (BOOL)isIPAddress:(NSString *)iPAddress{
NSString *pattern = @"^(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5]).(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5]).(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5]).(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])$";

return [self isText:[iPAddress componentsSeparatedByString:@"//"][1] pattern:pattern];
}
- (BOOL)isText:(NSString *)text pattern:(NSString *)pattern{
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",pattern];
return [predicate evaluateWithObject:text];
}

- (NSString *)getUserAgent:(NSString *)customUserAgent {
static NSString * userAgent = nil;
Expand Down
2 changes: 1 addition & 1 deletion AliyunOSSSDK/OSSNetworkingRequestDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ - (OSSTask *)buildInternalHttpRequest {
temComs.host = dnsResult;
}
} else if ([ipAdapter isIPv4Address:temComs.host] || [ipAdapter isIPv6Address:temComs.host]) {
temComs.path = [NSString stringWithFormat:@"/%@",self.allNeededMessage.bucketName];
// temComs.path = [NSString stringWithFormat:@"/%@",self.allNeededMessage.bucketName];
}
}

Expand Down