|
34 | 34 | public final class Blob { |
35 | 35 |
|
36 | 36 | private final Storage storage; |
37 | | - private BlobInfo info; |
| 37 | + private final BlobInfo info; |
38 | 38 |
|
39 | 39 | public static class BlobSourceOption extends Option { |
40 | 40 |
|
@@ -137,19 +137,31 @@ public byte[] content(Storage.BlobSourceOption... options) { |
137 | 137 | return storage.readAllBytes(info.bucket(), info.name(), options); |
138 | 138 | } |
139 | 139 |
|
| 140 | + /** |
| 141 | + * Fetches current blob's latest information. |
| 142 | + * |
| 143 | + * @param options blob read options |
| 144 | + * @return a {@code Blob} object with latest information |
| 145 | + * @throws StorageException upon failure |
| 146 | + */ |
| 147 | + public Blob reload(BlobSourceOption... options) { |
| 148 | + return new Blob(storage, storage.get(info.bucket(), info.name(), convert(info, options))); |
| 149 | + } |
| 150 | + |
140 | 151 | /** |
141 | 152 | * Update the blob's information. Bucket or blob's name cannot be changed by this method. If you |
142 | 153 | * want to rename the blob or move it to a different bucket use the {@link #copyTo} and |
143 | | - * {@link #delete} operations. |
| 154 | + * {@link #delete} operations. A new {@code Blob} object is returned. |
144 | 155 | * |
145 | 156 | * @param blobInfo new blob's information. Bucket and blob names must match the current ones |
146 | 157 | * @param options update options |
| 158 | + * @return a {@code Blob} object with updated information |
147 | 159 | * @throws StorageException upon failure |
148 | 160 | */ |
149 | | - public void update(BlobInfo blobInfo, BlobTargetOption... options) { |
| 161 | + public Blob update(BlobInfo blobInfo, BlobTargetOption... options) { |
150 | 162 | checkArgument(Objects.equals(blobInfo.bucket(), info.bucket()), "Bucket name must match"); |
151 | 163 | checkArgument(Objects.equals(blobInfo.name(), info.name()), "Blob name must match"); |
152 | | - info = storage.update(blobInfo, options); |
| 164 | + return new Blob(storage, storage.update(blobInfo, options)); |
153 | 165 | } |
154 | 166 |
|
155 | 167 | /** |
|
0 commit comments