|
18 | 18 |
|
19 | 19 | import com.google.gcloud.spi.StorageRpc.Tuple; |
20 | 20 | import com.google.gcloud.storage.BatchRequest; |
| 21 | +import com.google.gcloud.storage.BatchResponse; |
21 | 22 | import com.google.gcloud.storage.Blob; |
22 | 23 | import com.google.gcloud.storage.Bucket; |
23 | 24 | import com.google.gcloud.storage.StorageService; |
24 | | -import com.google.gcloud.storage.StorageService.CopyRequest; |
25 | 25 | import com.google.gcloud.storage.StorageService.ComposeRequest; |
| 26 | +import com.google.gcloud.storage.StorageService.CopyRequest; |
26 | 27 | import com.google.gcloud.storage.StorageServiceFactory; |
27 | 28 | import com.google.gcloud.storage.StorageServiceOptions; |
28 | 29 |
|
@@ -102,43 +103,51 @@ public String params() { |
102 | 103 | } |
103 | 104 | } |
104 | 105 |
|
105 | | - private static class InfoAction extends BlobAction { |
| 106 | + private static class InfoAction extends BlobsAction { |
106 | 107 | @Override |
107 | | - public void run(StorageService storage, Blob blob) { |
108 | | - if (blob.name().isEmpty()) { |
109 | | - System.out.println(storage.get(Bucket.of(blob.bucket()))); |
| 108 | + public void run(StorageService storage, Blob... blobs) { |
| 109 | + if (blobs.length == 1) { |
| 110 | + if (blobs[0].name().isEmpty()) { |
| 111 | + System.out.println(storage.get(Bucket.of(blobs[0].bucket()))); |
| 112 | + } else { |
| 113 | + System.out.println(storage.get(blobs[0])); |
| 114 | + } |
110 | 115 | } else { |
111 | | - System.out.println(storage.get(blob)); |
| 116 | + BatchRequest.Builder batch = BatchRequest.builder(); |
| 117 | + for (Blob blob : blobs) { |
| 118 | + batch.get(blob); |
| 119 | + } |
| 120 | + BatchResponse response = storage.apply(batch.build()); |
| 121 | + System.out.println(response.gets()); |
112 | 122 | } |
113 | 123 | } |
114 | 124 |
|
115 | 125 | @Override |
116 | | - Blob parse(String... args) { |
| 126 | + Blob[] parse(String... args) { |
117 | 127 | if (args.length < 2) { |
118 | | - return Blob.of(args[0], ""); |
| 128 | + return new Blob[] {Blob.of(args[0], "")}; |
119 | 129 | } |
120 | 130 | return super.parse(args); |
121 | 131 | } |
122 | 132 |
|
123 | 133 | @Override |
124 | 134 | public String params() { |
125 | | - return "<bucket> [<path>]"; |
| 135 | + return "<bucket> [<path>+]"; |
126 | 136 | } |
127 | 137 | } |
128 | 138 |
|
129 | 139 | private static class DeleteAction extends BlobsAction { |
130 | 140 | @Override |
131 | 141 | public void run(StorageService storage, Blob... blobs) { |
132 | 142 | if (blobs.length == 1) { |
133 | | - System.out.println("Calling delete"); |
134 | 143 | System.out.println(storage.delete(blobs[0])); |
135 | 144 | } else { |
136 | 145 | BatchRequest.Builder batch = BatchRequest.builder(); |
137 | 146 | for (Blob blob : blobs) { |
138 | 147 | batch.delete(blob); |
139 | 148 | } |
140 | | - System.out.println("Calling batch.delete"); |
141 | | - storage.apply(batch.build()); |
| 149 | + BatchResponse response = storage.apply(batch.build()); |
| 150 | + System.out.println(response.deletes()); |
142 | 151 | } |
143 | 152 | } |
144 | 153 | } |
|
0 commit comments