Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.2k
Add batch get, update, delete methods to Storage and Blob#233
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
fc3a2d7b1918cac552ede5bf23b6f1c6b04f2b6adcFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -20,12 +20,17 @@ | ||
| import static com.google.common.base.Preconditions.checkNotNull; | ||
| import static com.google.gcloud.storage.Blob.BlobSourceOption.convert; | ||
| import com.google.common.base.Function; | ||
| import com.google.common.collect.Lists; | ||
| import com.google.gcloud.spi.StorageRpc; | ||
| import com.google.gcloud.storage.Storage.BlobTargetOption; | ||
| import com.google.gcloud.storage.Storage.CopyRequest; | ||
| import com.google.gcloud.storage.Storage.SignUrlOption; | ||
| import java.net.URL; | ||
| import java.util.Arrays; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
| import java.util.Objects; | ||
| /** | ||
| @@ -256,4 +261,74 @@ public URL signUrl(long expirationTimeInSeconds, SignUrlOption... options) { | ||
| public Storage storage() { | ||
| return storage; | ||
| } | ||
| /** | ||
| * Gets the requested blobs. If {@code infos.length == 0} an empty list is returned. If | ||
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page. | ||
| * {@code infos.length > 1} a batch request is used to fetch blobs. | ||
| * | ||
| * @param storage the storage service used to issue the request | ||
| * @param infos the blobs to get | ||
| * @return an immutable list of {@code Blob} objects. If a blob does not exist or access to it has | ||
| * been denied the corresponding item in the list is {@code null}. | ||
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page. | ||
| * @throws StorageException upon failure | ||
| */ | ||
| public static List<Blob> get(final Storage storage, BlobInfo... infos) { | ||
| checkNotNull(storage); | ||
| checkNotNull(infos); | ||
| if (infos.length == 0) { | ||
| return Collections.emptyList(); | ||
| } | ||
| return Collections.unmodifiableList(Lists.transform(storage.get(infos), | ||
| new Function<BlobInfo, Blob>() { | ||
| @Override | ||
| public Blob apply(BlobInfo f) { | ||
| return f != null ? new Blob(storage, f) : null; | ||
| } | ||
| })); | ||
| } | ||
| /** | ||
| * Updates the requested blobs. If {@code infos.length == 0} an empty list is returned. If | ||
| * {@code infos.length > 1} a batch request is used to update blobs. | ||
| * | ||
| * @param storage the storage service used to issue the request | ||
| * @param infos the blobs to update | ||
| * @return an immutable list of {@code Blob} objects. If a blob does not exist or access to it has | ||
| * been denied the corresponding item in the list is {@code null}. | ||
| * @throws StorageException upon failure | ||
| */ | ||
| public static List<Blob> update(final Storage storage, BlobInfo... infos) { | ||
| checkNotNull(storage); | ||
| checkNotNull(infos); | ||
| if (infos.length == 0) { | ||
| return Collections.emptyList(); | ||
| } | ||
| return Collections.unmodifiableList(Lists.transform(storage.update(infos), | ||
| new Function<BlobInfo, Blob>() { | ||
| @Override | ||
| public Blob apply(BlobInfo f) { | ||
| return f != null ? new Blob(storage, f) : null; | ||
| } | ||
| })); | ||
| } | ||
| /** | ||
| * Deletes the requested blobs. If {@code infos.length == 0} an empty list is returned. If | ||
| * {@code infos.length > 1} a batch request is used to delete blobs. | ||
| * | ||
| * @param storage the storage service used to issue the request | ||
| * @param infos the blobs to delete | ||
| * @return an immutable list of booleans. If a blob has been deleted the corresponding item in the | ||
| * list is {@code true}. If deletion failed or access to the resource was denied the item is | ||
| * {@code false}. | ||
| * @throws StorageException upon failure | ||
| */ | ||
| public static List<Boolean> delete(Storage storage, BlobInfo... infos) { | ||
| checkNotNull(storage); | ||
| checkNotNull(infos); | ||
| if (infos.length == 0) { | ||
| return Collections.emptyList(); | ||
| } | ||
| return storage.delete(infos); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -563,6 +563,14 @@ public static Builder builder() { | ||
| */ | ||
| BlobInfo update(BlobInfo blobInfo, BlobTargetOption... options); | ||
| /** | ||
| * Update blob information. | ||
| * | ||
| * @return the updated blob | ||
| * @throws StorageException upon failure | ||
| */ | ||
| BlobInfo update(BlobInfo blobInfo); | ||
| /** | ||
| * Delete the requested bucket. | ||
| * | ||
| @@ -638,4 +646,35 @@ public static Builder builder() { | ||
| * @see <a href="https://cloud.google.com/storage/docs/access-control#Signed-URLs">Signed-URLs</a> | ||
| */ | ||
| URL signUrl(BlobInfo blobInfo, long expirationTimeInSeconds, SignUrlOption... options); | ||
| /** | ||
| * Gets the requested blobs. A batch request is used to perform this call. | ||
| * | ||
| * @param blobInfos blobs to get | ||
| * @return an immutable list of {@code BlobInfo} objects. If a blob does not exist or access to it | ||
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page. | ||
| * has been denied the corresponding item in the list is {@code null}. | ||
| * @throws StorageException upon failure | ||
| */ | ||
| List<BlobInfo> get(BlobInfo... blobInfos); | ||
| /** | ||
| * Updates the requested blobs. A batch request is used to perform this call. | ||
| * | ||
| * @param blobInfos blobs to update | ||
| * @return an immutable list of {@code BlobInfo} objects. If a blob does not exist or access to it | ||
| * has been denied the corresponding item in the list is {@code null}. | ||
| * @throws StorageException upon failure | ||
| */ | ||
| List<BlobInfo> update(BlobInfo... blobInfos); | ||
| /** | ||
| * Deletes the requested blobs. A batch request is used to perform this call. | ||
| * | ||
| * @param blobInfos blobs to delete | ||
| * @return an immutable list of booleans. If a blob has been deleted the corresponding item in the | ||
| * list is {@code true}. If deletion failed or access to the resource was denied the item is | ||
| * {@code false}. | ||
| * @throws StorageException upon failure | ||
| */ | ||
| List<Boolean> delete(BlobInfo... blobInfos); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.