Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add api of GetBucketV2 #320

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
24 changes: 24 additions & 0 deletions AliyunOSSSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@

/* Begin PBXBuildFile section */
4CEF14F81F5522A1007010B8 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 216256EF1CF1B1580086458F /* SystemConfiguration.framework */; };
5423CD292845F647005B4BCE /* OSSGetBucketV2Request.h in Headers */ = {isa = PBXBuildFile; fileRef = 5423CD272845F647005B4BCE /* OSSGetBucketV2Request.h */; settings = {ATTRIBUTES = (Public, ); }; };
5423CD2A2845F647005B4BCE /* OSSGetBucketV2Request.h in Headers */ = {isa = PBXBuildFile; fileRef = 5423CD272845F647005B4BCE /* OSSGetBucketV2Request.h */; settings = {ATTRIBUTES = (Public, ); }; };
5423CD2B2845F647005B4BCE /* OSSGetBucketV2Request.m in Sources */ = {isa = PBXBuildFile; fileRef = 5423CD282845F647005B4BCE /* OSSGetBucketV2Request.m */; };
5423CD2C2845F647005B4BCE /* OSSGetBucketV2Request.m in Sources */ = {isa = PBXBuildFile; fileRef = 5423CD282845F647005B4BCE /* OSSGetBucketV2Request.m */; };
5423CD2F2845F66E005B4BCE /* OSSGetBucketV2Result.h in Headers */ = {isa = PBXBuildFile; fileRef = 5423CD2D2845F66E005B4BCE /* OSSGetBucketV2Result.h */; settings = {ATTRIBUTES = (Public, ); }; };
5423CD302845F66E005B4BCE /* OSSGetBucketV2Result.h in Headers */ = {isa = PBXBuildFile; fileRef = 5423CD2D2845F66E005B4BCE /* OSSGetBucketV2Result.h */; settings = {ATTRIBUTES = (Public, ); }; };
5423CD312845F66E005B4BCE /* OSSGetBucketV2Result.m in Sources */ = {isa = PBXBuildFile; fileRef = 5423CD2E2845F66E005B4BCE /* OSSGetBucketV2Result.m */; };
5423CD322845F66E005B4BCE /* OSSGetBucketV2Result.m in Sources */ = {isa = PBXBuildFile; fileRef = 5423CD2E2845F66E005B4BCE /* OSSGetBucketV2Result.m */; };
D80C81F51FC824E2008E3900 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D80C81F41FC824D5008E3900 /* SystemConfiguration.framework */; };
D80C81F71FC824FF008E3900 /* CoreTelephony.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D80C81F61FC824FF008E3900 /* CoreTelephony.framework */; };
D80C81FB1FC82541008E3900 /* OSSModel.h in Headers */ = {isa = PBXBuildFile; fileRef = D87183091FC56358000DD9EC /* OSSModel.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -223,6 +231,10 @@
216256EF1CF1B1580086458F /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
4C7D8BB61F8CC70F005D3040 /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = System/Library/Frameworks/CFNetwork.framework; sourceTree = SDKROOT; };
4C7D8BB81F8CC741005D3040 /* CoreTelephony.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreTelephony.framework; path = System/Library/Frameworks/CoreTelephony.framework; sourceTree = SDKROOT; };
5423CD272845F647005B4BCE /* OSSGetBucketV2Request.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OSSGetBucketV2Request.h; sourceTree = "<group>"; };
5423CD282845F647005B4BCE /* OSSGetBucketV2Request.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OSSGetBucketV2Request.m; sourceTree = "<group>"; };
5423CD2D2845F66E005B4BCE /* OSSGetBucketV2Result.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OSSGetBucketV2Result.h; sourceTree = "<group>"; };
5423CD2E2845F66E005B4BCE /* OSSGetBucketV2Result.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OSSGetBucketV2Result.m; sourceTree = "<group>"; };
D80C81EC1FC824A8008E3900 /* AliyunOSSOSX.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = AliyunOSSOSX.framework; sourceTree = BUILT_PRODUCTS_DIR; };
D80C81F41FC824D5008E3900 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/SystemConfiguration.framework; sourceTree = DEVELOPER_DIR; };
D80C81F61FC824FF008E3900 /* CoreTelephony.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreTelephony.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreTelephony.framework; sourceTree = DEVELOPER_DIR; };
Expand Down Expand Up @@ -464,6 +476,10 @@
D827B4162111A6E4003A24F6 /* OSSPutSymlinkRequest.m */,
D827B42D2111ADE9003A24F6 /* OSSPutSymlinkResult.h */,
D827B42E2111ADE9003A24F6 /* OSSPutSymlinkResult.m */,
5423CD272845F647005B4BCE /* OSSGetBucketV2Request.h */,
5423CD282845F647005B4BCE /* OSSGetBucketV2Request.m */,
5423CD2D2845F66E005B4BCE /* OSSGetBucketV2Result.h */,
5423CD2E2845F66E005B4BCE /* OSSGetBucketV2Result.m */,
D85277E92015BBAD00D7B1DE /* OSSRequest.h */,
D85277EA2015BBAD00D7B1DE /* OSSRequest.m */,
D827B4212111A71B003A24F6 /* OSSRestoreObjectRequest.h */,
Expand Down Expand Up @@ -547,6 +563,7 @@
D8C41B211FCC2FD20091699B /* OSSClient.h in Headers */,
D8C41B231FCC2FD20091699B /* OSSHttpdns.h in Headers */,
D8C41B241FCC2FD20091699B /* OSSNetworking.h in Headers */,
5423CD292845F647005B4BCE /* OSSGetBucketV2Request.h in Headers */,
D8C41B251FCC2FD20091699B /* OSSIPv6Adapter.h in Headers */,
D8C41B2A1FCC2FD20091699B /* OSSIPv6PrefixResolver.h in Headers */,
D8C41B2B1FCC2FD20091699B /* OSSDefine.h in Headers */,
Expand Down Expand Up @@ -581,6 +598,7 @@
D827B41D2111A6FA003A24F6 /* OSSGetSymlinkRequest.h in Headers */,
D827B4352111ADF7003A24F6 /* OSSGetSymlinkResult.h in Headers */,
D8C2951220F46A79008A08AA /* OSSGetBucketInfoRequest.h in Headers */,
5423CD2F2845F66E005B4BCE /* OSSGetBucketV2Result.h in Headers */,
D8C2951820F46A95008A08AA /* OSSGetBucketInfoResult.h in Headers */,
D827B40B21107169003A24F6 /* NSDate+OSS.h in Headers */,
D8C41B411FCC2FD20091699B /* OSSFileLogger.h in Headers */,
Expand All @@ -604,6 +622,7 @@
D80C82131FC82596008E3900 /* OSSIPv6Adapter.h in Headers */,
D80C82051FC82567008E3900 /* OSSService.h in Headers */,
D80C82041FC82562008E3900 /* OSSLog.h in Headers */,
5423CD2A2845F647005B4BCE /* OSSGetBucketV2Request.h in Headers */,
D80C82151FC8259C008E3900 /* OSSIPv6PrefixResolver.h in Headers */,
D80C82061FC8256D008E3900 /* OSSLogMacros.h in Headers */,
D80C82081FC82571008E3900 /* OSSReachability.h in Headers */,
Expand Down Expand Up @@ -638,6 +657,7 @@
D827B4362111ADF7003A24F6 /* OSSGetSymlinkResult.h in Headers */,
D8C2951320F46A79008A08AA /* OSSGetBucketInfoRequest.h in Headers */,
D8C2951920F46A95008A08AA /* OSSGetBucketInfoResult.h in Headers */,
5423CD302845F66E005B4BCE /* OSSGetBucketV2Result.h in Headers */,
D80C88E8201B06CF00F379D8 /* OSSDeleteMultipleObjectsRequest.h in Headers */,
D80C82011FC82559008E3900 /* OSSHttpdns.h in Headers */,
D827B40C21107169003A24F6 /* NSDate+OSS.h in Headers */,
Expand Down Expand Up @@ -809,6 +829,7 @@
D8C41AF71FCC2F920091699B /* OSSIPv6Adapter.m in Sources */,
D827B4192111A6E4003A24F6 /* OSSPutSymlinkRequest.m in Sources */,
D8C41AFA1FCC2F920091699B /* OSSCompat.m in Sources */,
5423CD2B2845F647005B4BCE /* OSSGetBucketV2Request.m in Sources */,
D8C41AFC1FCC2F920091699B /* OSSCancellationTokenRegistration.m in Sources */,
D8C41AFD1FCC2F920091699B /* OSSBolts.m in Sources */,
D8C41AFF1FCC2F920091699B /* OSSTaskCompletionSource.m in Sources */,
Expand All @@ -823,6 +844,7 @@
D8C41B0A1FCC2F920091699B /* OSSXMLDictionary.m in Sources */,
D827B41F2111A6FA003A24F6 /* OSSGetSymlinkRequest.m in Sources */,
D852780C2015D59000D7B1DE /* OSSURLRequestRetryHandler.m in Sources */,
5423CD312845F66E005B4BCE /* OSSGetBucketV2Result.m in Sources */,
D85277ED2015BBAD00D7B1DE /* OSSRequest.m in Sources */,
D827B4312111ADE9003A24F6 /* OSSPutSymlinkResult.m in Sources */,
D827B41321114E4B003A24F6 /* NSMutableDictionary+OSS.m in Sources */,
Expand Down Expand Up @@ -861,6 +883,7 @@
D8C41AB81FCC284F0091699B /* OSSIPv6Adapter.m in Sources */,
D827B41A2111A6E4003A24F6 /* OSSPutSymlinkRequest.m in Sources */,
D8C41ABB1FCC284F0091699B /* OSSCompat.m in Sources */,
5423CD2C2845F647005B4BCE /* OSSGetBucketV2Request.m in Sources */,
D8C41ABD1FCC284F0091699B /* OSSCancellationTokenRegistration.m in Sources */,
D8C41ABE1FCC284F0091699B /* OSSBolts.m in Sources */,
D8C41AC01FCC284F0091699B /* OSSTaskCompletionSource.m in Sources */,
Expand All @@ -875,6 +898,7 @@
D8C41ACB1FCC28500091699B /* OSSXMLDictionary.m in Sources */,
D827B4202111A6FA003A24F6 /* OSSGetSymlinkRequest.m in Sources */,
D852780D2015D59000D7B1DE /* OSSURLRequestRetryHandler.m in Sources */,
5423CD322845F66E005B4BCE /* OSSGetBucketV2Result.m in Sources */,
D85277EE2015BBAD00D7B1DE /* OSSRequest.m in Sources */,
D827B4322111ADE9003A24F6 /* OSSPutSymlinkResult.m in Sources */,
D827B41421114E4B003A24F6 /* NSMutableDictionary+OSS.m in Sources */,
Expand Down
3 changes: 2 additions & 1 deletion AliyunOSSSDK/OSSAllRequestNeededMessage.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ - (OSSTask *)validateRequestParamsInOperationType:(OSSOperationType)operType {
}

if (!self.objectKey &&
(operType != OSSOperationTypeGetBucket && operType != OSSOperationTypeCreateBucket
(operType != OSSOperationTypeGetBucket && operType != OSSOperationTypeGetBucketV2
&& operType != OSSOperationTypeCreateBucket
&& operType != OSSOperationTypeDeleteBucket && operType != OSSOperationTypeGetService
&& operType != OSSOperationTypeGetBucketACL&& operType != OSSOperationTypeDeleteMultipleObjects
&& operType != OSSOperationTypeListMultipartUploads
Expand Down
7 changes: 7 additions & 0 deletions AliyunOSSSDK/OSSClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
@class OSSPutSymlinkRequest;
@class OSSGetSymlinkRequest;
@class OSSRestoreObjectRequest;
@class OSSGetBucketV2Request;

@class OSSTask;
@class OSSExecutor;
Expand Down Expand Up @@ -133,6 +134,12 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (OSSTask *)getBucket:(OSSGetBucketRequest *)request;

/**
The corresponding RESTFul API: GetBucketV2
Lists all objects in a bucket. It could be specified with filters such as prefix, marker, delimeter and max-keys.
*/
- (OSSTask *)getBucketV2:(OSSGetBucketV2Request *)request;

/**
The corresponding RESTFul API: GetBucketInfo
Gets the {@link Bucket}'s basic information as well as its ACL.
Expand Down
18 changes: 18 additions & 0 deletions AliyunOSSSDK/OSSClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#import "OSSPutSymlinkRequest.h"
#import "OSSGetSymlinkRequest.h"
#import "OSSRestoreObjectRequest.h"
#import "OSSGetBucketV2Request.h""

static NSString * const kClientRecordNameWithCommonPrefix = @"oss_partInfos_storage_name";
static NSString * const kClientRecordNameWithCRC64Suffix = @"-crc64";
Expand Down Expand Up @@ -495,6 +496,23 @@ - (OSSTask *)getBucket:(OSSGetBucketRequest *)request {
return [self invokeRequest:requestDelegate requireAuthentication:request.isAuthenticationRequired];
}

- (OSSTask *)getBucketV2:(OSSGetBucketV2Request *)request {
OSSNetworkingRequestDelegate * requestDelegate = request.requestDelegate;

requestDelegate.responseParser = [[OSSHttpResponseParser alloc] initForOperationType:OSSOperationTypeGetBucketV2];

OSSAllRequestNeededMessage *neededMsg = [[OSSAllRequestNeededMessage alloc] init];
neededMsg.endpoint = self.endpoint;
neededMsg.httpMethod = OSSHTTPMethodGET;
neededMsg.bucketName = request.bucketName;
neededMsg.params = request.requestParams;
requestDelegate.allNeededMessage = neededMsg;

requestDelegate.operType = OSSOperationTypeGetBucketV2;

return [self invokeRequest:requestDelegate requireAuthentication:request.isAuthenticationRequired];
}

- (OSSTask *)getBucketInfo:(OSSGetBucketInfoRequest *)request {
OSSNetworkingRequestDelegate * requestDelegate = request.requestDelegate;

Expand Down
1 change: 1 addition & 0 deletions AliyunOSSSDK/OSSConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ typedef NS_ENUM(NSInteger, OSSOperationType) {
OSSOperationTypeCreateBucket,
OSSOperationTypeDeleteBucket,
OSSOperationTypeGetBucket,
OSSOperationTypeGetBucketV2,
OSSOperationTypeGetBucketInfo,
OSSOperationTypeGetBucketACL,
OSSOperationTypeHeadObject,
Expand Down
11 changes: 11 additions & 0 deletions AliyunOSSSDK/OSSDefine.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@
#define OSSUploadIdMarkerXMLTOKEN @"UploadIdMarker"
#define OSSNextUploadIdMarkerXMLTOKEN @"NextUploadIdMarker"
#define OSSMaxKeysXMLTOKEN @"MaxKeys"
#define OSSKeyCountXMLTOKEN @"KeyCount"
#define OSSMaxUploadsXMLTOKEN @"MaxUploads"
#define OSSIsTruncatedXMLTOKEN @"IsTruncated"
#define OSSContentsXMLTOKEN @"Contents"
#define OSSNextContinuationTokenXMLTOKEN @"NextContinuationToken"
#define OSSUploadXMLTOKEN @"Upload"
#define OSSKeyXMLTOKEN @"Key"
#define OSSLastModifiedXMLTOKEN @"LastModified"
Expand All @@ -55,6 +57,15 @@
#define OSSPartXMLTOKEN @"Part"
#define OSSPartNumberXMLTOKEN @"PartNumber"

#define OSSSubResourceListType @"list-type"
#define OSSSubResourceDelimiter @"delimiter"
#define OSSSubResourceStartAfter @"start-after"
#define OSSSubResourceContinuationToken @"continuation-token"
#define OSSSubResourceMaxKeys @"max-keys"
#define OSSSubResourcePrefix @"prefix"
#define OSSSubResourceEncodingType @"encoding-type"
#define OSSSubResourceFetchOwner @"fetch-owner"

#define OSSClientErrorDomain @"com.aliyun.oss.clientError"
#define OSSServerErrorDomain @"com.aliyun.oss.serverError"

Expand Down
48 changes: 48 additions & 0 deletions AliyunOSSSDK/OSSGetBucketV2Request.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//
// OSSListObjectsV2Request.h
// AliyunOSSSDK
//
// Created by ws on 2022/5/26.
// Copyright © 2022 aliyun. All rights reserved.
//

#import "OSSRequest.h"

NS_ASSUME_NONNULL_BEGIN

@interface OSSGetBucketV2Request : OSSRequest

/**
Bucket name
*/
@property (nonatomic, copy) NSString *bucketName;

/// Optional parameter indicating the encoding method to be applied on the
/// response. An object key can contain any Unicode character; however, XML
/// 1.0 parser cannot parse some characters, such as characters with an ASCII
/// value from 0 to 10. you can add this parameter to request that OSS encode the keys in the
/// response.
@property (nonatomic, copy) NSString *delimiter;

/// Optional parameter indicating the maximum number of keys to include in the response.
@property (nonatomic, copy) NSString *encodingType;

/// Optional parameter restricting the response to keys which begin with the specified prefix.
@property (nonatomic) NSInteger maxKeys;

/// Optional parameter restricting the response to keys which begin with the specified prefix.
@property (nonatomic, copy) NSString *prefix;

/// Optional parameter which allows list to be continued from a specific point.
/// ContinuationToken is provided in truncated list results.
@property (nonatomic, copy) NSString *continuationToken;

/// The owner field is not present in ListObjectsV2 results by default. If this flag is set to true the owner field will be returned.
@property (nonatomic) BOOL fetchOwner;

/// Optional parameter indicating where you want OSS to start the object listing from.
@property (nonatomic, copy) NSString *startAfter;

@end

NS_ASSUME_NONNULL_END
38 changes: 38 additions & 0 deletions AliyunOSSSDK/OSSGetBucketV2Request.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// OSSListObjectsV2Request.m
// AliyunOSSSDK
//
// Created by ws on 2022/5/26.
// Copyright © 2022 aliyun. All rights reserved.
//

#import "OSSGetBucketV2Request.h"
#import "NSMutableDictionary+OSS.h"
#import "OSSDefine.h"

@implementation OSSGetBucketV2Request

- (instancetype)init {
self = [super init];
if (self) {
self.maxKeys = 100;
self.fetchOwner = NO;
}
return self;
}

- (NSDictionary *)requestParams {
NSMutableDictionary *params = [NSMutableDictionary dictionary];
[params oss_setObject:@"2" forKey:OSSSubResourceListType];
[params oss_setObject:self.delimiter forKey:OSSSubResourceDelimiter];
[params oss_setObject:self.startAfter forKey:OSSSubResourceStartAfter];
[params oss_setObject:self.continuationToken forKey:OSSSubResourceContinuationToken];
[params oss_setObject:[@(self.maxKeys) stringValue] forKey:OSSSubResourceMaxKeys];
[params oss_setObject:self.prefix forKey:OSSSubResourcePrefix];
[params oss_setObject:self.encodingType forKey:OSSSubResourceEncodingType];
NSString *fetchOwner = self.fetchOwner ? @"true": @"false";
[params oss_setObject:fetchOwner forKey:OSSSubResourceFetchOwner];
return [params copy];
}

@end
53 changes: 53 additions & 0 deletions AliyunOSSSDK/OSSGetBucketV2Result.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//
// OSSListObjectsV2Result.h
// AliyunOSSSDK
//
// Created by ws on 2022/5/26.
// Copyright © 2022 aliyun. All rights reserved.
//

#import "OSSResult.h"

NS_ASSUME_NONNULL_BEGIN

@interface OSSGetBucketV2Result : OSSResult

/// A list of summary information describing the objects stored in the bucket
@property (nonatomic, copy, nullable) NSArray *contents;

/// A list of the common prefixes included in this object listing - common prefixes will only be populated for requests that specified a delimiter
@property (nonatomic, copy) NSArray<NSString *> *commonPrefixes;

/// The name of the bucket
@property (nonatomic, copy) NSString *bucketName;

/// KeyCount is the number of keys returned with this response
@property (nonatomic) NSInteger keyCount;

/// Optional parameter which allows list to be continued from a specific point. ContinuationToken is provided in truncated list results.
@property (nonatomic, copy) NSString *continuationToken;

/// NextContinuationToken is sent when isTruncated is true meaning there are more keys in the bucket that can be listed.
@property (nonatomic, copy) NSString *nextContinuationToken;

/// Optional parameter indicating where you want OSS to start the object listing from. This can be any key in the bucket.
@property (nonatomic, copy) NSString *startAfter;

/// Indicates if this is a complete listing, or if the caller needs to make additional requests to OSS to see the full object listing.
@property (nonatomic) BOOL isTruncated;

/// The prefix parameter originally specified by the caller when this object listing was returned
@property (nonatomic, copy) NSString *prefix;

/// The maxKeys parameter originally specified by the caller when this object listing was returned
@property (nonatomic) NSInteger maxKeys;

/// The delimiter parameter originally specified by the caller when this object listing was returned
@property (nonatomic, copy) NSString *delimiter;

/// The encodingType parameter originally specified by the caller when this object listing was returned.
@property (nonatomic, copy) NSString *encodingType;

@end

NS_ASSUME_NONNULL_END
13 changes: 13 additions & 0 deletions AliyunOSSSDK/OSSGetBucketV2Result.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// OSSListObjectsV2Result.m
// AliyunOSSSDK
//
// Created by ws on 2022/5/26.
// Copyright © 2022 aliyun. All rights reserved.
//

#import "OSSGetBucketV2Result.h"

@implementation OSSGetBucketV2Result

@end
Loading