Skip to content

Commit 86065a7

Browse files
committed
Rename Storage.createFromStream create, add create for empty content
1 parent 82cd3ea commit 86065a7

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,14 @@ public static Builder builder() {
493493
*/
494494
BucketInfo create(BucketInfo bucketInfo, BucketTargetOption... options);
495495

496+
/**
497+
* Create a new blob with no content.
498+
*
499+
* @return a complete blob information.
500+
* @throws StorageException upon failure
501+
*/
502+
BlobInfo create(BlobInfo blobInfo, BlobTargetOption... options);
503+
496504
/**
497505
* Create a new blob. Direct upload is used to upload {@code content}. For large content,
498506
* {@link #writer} is recommended as it uses resumable upload.
@@ -509,7 +517,7 @@ public static Builder builder() {
509517
* @return a complete blob information.
510518
* @throws StorageException upon failure
511519
*/
512-
BlobInfo createFromStream(BlobInfo blobInfo, InputStream content, BlobTargetOption... options);
520+
BlobInfo create(BlobInfo blobInfo, InputStream content, BlobTargetOption... options);
513521

514522
/**
515523
* Return the requested bucket or {@code null} if not found.

gcloud-java-storage/src/main/java/com/google/gcloud/storage/StorageImpl.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,19 @@ public com.google.api.services.storage.model.Bucket call() {
114114
}, options().retryParams(), EXCEPTION_HANDLER));
115115
}
116116

117+
@Override
118+
public BlobInfo create(BlobInfo blobInfo, BlobTargetOption... options) {
119+
return create(blobInfo, new ByteArrayInputStream(EMPTY_BYTE_ARRAY), options);
120+
}
121+
117122
@Override
118123
public BlobInfo create(BlobInfo blobInfo, final byte[] content, BlobTargetOption... options) {
119-
return createFromStream(blobInfo,
124+
return create(blobInfo,
120125
new ByteArrayInputStream(firstNonNull(content, EMPTY_BYTE_ARRAY)), options);
121126
}
122127

123128
@Override
124-
public BlobInfo createFromStream(BlobInfo blobInfo, final InputStream content,
129+
public BlobInfo create(BlobInfo blobInfo, final InputStream content,
125130
BlobTargetOption... options) {
126131
final StorageObject blobPb = blobInfo.toPb();
127132
final Map<StorageRpc.Option, ?> optionsMap = optionMap(blobInfo, options);

0 commit comments

Comments
 (0)