Browse Source

chore: modify asyncListObjects in ios platform

罗章 6 years ago
parent
commit
6d492d372a
1 changed files with 18 additions and 6 deletions
  1. 18
    6
      ios/RNAliyunOSS+OBJECT.m

+ 18
- 6
ios/RNAliyunOSS+OBJECT.m View File

@@ -13,21 +13,33 @@
13 13
  asyncListObjects
14 14
  */
15 15
 
16
-RCT_REMAP_METHOD(asyncListObjects, bucketName:(NSString*)bucketName prefix:(NSString*)prefix resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
16
+RCT_REMAP_METHOD(asyncListObjects, bucketName:(NSString*)bucketName options:(NSDictionary*)options resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
17 17
     OSSGetBucketRequest * getBucket = [OSSGetBucketRequest new];
18 18
     getBucket.bucketName = bucketName;
19 19
     // 可选参数,具体含义参考:https://docs.aliyun.com/#/pub/oss/api-reference/bucket&GetBucket
20 20
     // getBucket.marker = @"";
21
-    getBucket.prefix = prefix;
22 21
     // getBucket.delimiter = @"";
22
+    
23
+    if([options objectForKey:@"delimiter"]) {
24
+        getBucket.delimiter = [options objectForKey:@"delimiter"];
25
+    }
26
+    
27
+    if([options objectForKey:@"marker"]) {
28
+        getBucket.delimiter = [options objectForKey:@"marker"];
29
+    }
30
+    
31
+    if([options objectForKey:@"prefix"]) {
32
+        getBucket.delimiter = [options objectForKey:@"prefix"];
33
+    }
34
+    
35
+    if([options objectForKey:@"maxkeys"]) {
36
+        getBucket.delimiter = [options objectForKey:@"maxkeys"];
37
+    }
38
+    
23 39
     OSSTask * getBucketTask = [self.client getBucket:getBucket];
24 40
     [getBucketTask continueWithBlock:^id(OSSTask *task) {
25 41
         if (!task.error) {
26 42
             OSSGetBucketResult * result = task.result;
27
-            //            NSLog(@"get bucket success!");
28
-            //            for (NSDictionary * objectInfo in result.contents) {
29
-            //                NSLog(@"list object: %@", objectInfo);
30
-            //            }
31 43
             resolve(result.contents);
32 44
         } else {
33 45
             NSLog(@"get bucket failed, error: %@", task.error);