Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/main/java/com/google/gcloud/examples/StorageExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@ private static class InfoAction extends BlobsAction {
public void run(StorageService storage, Blob... blobs) {
if (blobs.length == 1) {
if (blobs[0].name().isEmpty()) {
System.out.println(storage.get(Bucket.of(blobs[0].bucket())));
System.out.println(storage.get(blobs[0].bucket()));
} else {
System.out.println(storage.get(blobs[0]));
System.out.println(storage.get(blobs[0].bucket(), blobs[0].name()));
}
} else {
BatchRequest.Builder batch = BatchRequest.builder();
for (Blob blob : blobs) {
batch.get(blob);
batch.get(blob.bucket(), blob.name());
}
BatchResponse response = storage.apply(batch.build());
System.out.println(response.gets());
Expand All @@ -149,11 +149,11 @@ private static class DeleteAction extends BlobsAction {
@Override
public void run(StorageService storage, Blob... blobs) {
if (blobs.length == 1) {
System.out.println(storage.delete(blobs[0]));
System.out.println(storage.delete(blobs[0].bucket(), blobs[0].name()));
} else {
BatchRequest.Builder batch = BatchRequest.builder();
for (Blob blob : blobs) {
batch.delete(blob);
batch.delete(blob.bucket(), blob.name());
}
BatchResponse response = storage.apply(batch.build());
System.out.println(response.deletes());
Expand Down Expand Up @@ -236,7 +236,7 @@ private static class DownloadAction extends StorageAction<Tuple<Blob, Path>> {

@Override
public void run(StorageService storage, Tuple<Blob, Path> tuple) throws IOException {
Blob blob = storage.get(tuple.x());
Blob blob = storage.get(tuple.x().bucket(), tuple.x().name());
if (blob == null) {
System.out.println("No such object");
return;
Expand All @@ -246,9 +246,9 @@ public void run(StorageService storage, Tuple<Blob, Path> tuple) throws IOExcept
writeTo = new PrintStream(new FileOutputStream(tuple.y().toFile()));
}
if (blob.size() < 1024) {
writeTo.write(storage.load(blob));
writeTo.write(storage.load(blob.bucket(), blob.name()));
} else {
try (BlobReadChannel reader = storage.reader(blob)) {
try (BlobReadChannel reader = storage.reader(blob.bucket(), blob.name())) {
WritableByteChannel channel = Channels.newChannel(writeTo);
ByteBuffer bytes = ByteBuffer.allocate(64 * 1024);
while (reader.read(bytes) > 0) {
Expand Down Expand Up @@ -299,7 +299,7 @@ CopyRequest parse(String... args) {
if (args.length != 4) {
throw new IllegalArgumentException();
}
return CopyRequest.of(Blob.of(args[0], args[1]), Blob.of(args[2], args[3]));
return CopyRequest.of(args[0], args[1], Blob.of(args[2], args[3]));
}

@Override
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/google/gcloud/storage/BatchRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ private Builder() {}
/**
* Delete the given blob.
*/
public void delete(Blob blob, BlobSourceOption... options) {
toDelete.put(blob, options);
public void delete(String bucket, String blob, BlobSourceOption... options) {
toDelete.put(Blob.of(bucket, blob), options);
}

/**
Expand All @@ -60,8 +60,8 @@ public void update(Blob blob, BlobTargetOption... options) {
/**
* Retrieve metadata for the given blob.
*/
public void get(Blob blob, BlobSourceOption... options) {
toGet.put(blob, options);
public void get(String bucket, String blob, BlobSourceOption... options) {
toGet.put(Blob.of(bucket, blob), options);
}

public BatchRequest build() {
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/com/google/gcloud/storage/BatchResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@
*/
public class BatchResponse implements Serializable {

private List<Result<Boolean>> deleteResult;
private List<Result<Blob>> updateResult;
private List<Result<Blob>> getResult;
private static final long serialVersionUID = 1057416839397037706L;

private final List<Result<Boolean>> deleteResult;
private final List<Result<Blob>> updateResult;
private final List<Result<Blob>> getResult;

public static class Result<T extends Serializable> implements Serializable {

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/google/gcloud/storage/Option.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Option implements Serializable {

Option(StorageRpc.Option rpcOption, Object value) {
this.rpcOption = checkNotNull(rpcOption);
this.value = checkNotNull(value);
this.value = value;
}

StorageRpc.Option rpcOption() {
Expand Down
Loading