File tree 1 file changed +13
-4
lines changed
storage/s3-sdk/src/main/java 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change 36
36
import com .amazonaws .client .builder .AwsClientBuilder ;
37
37
import com .amazonaws .services .s3 .AmazonS3 ;
38
38
import com .amazonaws .services .s3 .AmazonS3ClientBuilder ;
39
- import com .amazonaws .services .s3 .model .AmazonS3Exception ;
40
39
import com .amazonaws .services .s3 .model .Bucket ;
40
+
41
41
import java .util .List ;
42
42
43
43
public class S3Sdk {
44
44
public static List <Bucket > listGcsBuckets () {
45
45
// Change the endpoint_url to use the Google Cloud Storage XML API endpoint.
46
- AmazonS3 s3 =
46
+ AmazonS3 interopClient =
47
47
AmazonS3ClientBuilder .standard ()
48
48
.withEndpointConfiguration (
49
49
new AwsClientBuilder .EndpointConfiguration (
50
50
"https://storage.googleapis.com" , "auto" ))
51
51
.build ();
52
52
53
53
// Call GCS to list current buckets
54
- List <Bucket > buckets = s3 .listBuckets ();
54
+ List <Bucket > buckets = interopClient .listBuckets ();
55
55
56
56
// Print bucket names
57
57
System .out .println ("Buckets:" );
58
58
for (Bucket bucket : buckets ) {
59
59
System .out .println (bucket .getName ());
60
60
}
61
+
62
+ // Explicitly clean up client resources.
63
+ interopClient .shutdown ();
64
+
61
65
return buckets ;
62
66
}
67
+ // [END storage_s3_sdk_list_buckets]
68
+
69
+ public static void main (String [] args ) {
70
+ listGcsBuckets ();
71
+ }
63
72
}
64
- // [END storage_s3_sdk_list_buckets]
73
+
You can’t perform that action at this time.
0 commit comments