Java idiomatic client for [Google Cloud Storage] (https://cloud.google.com/storage/).
- [Homepage] (https://googlecloudplatform.github.io/gcloud-java/)
- [API Documentation] (http://googlecloudplatform.github.io/gcloud-java/apidocs/index.html?com/google/gcloud/storage/package-summary.html)
Note: This client is a work-in-progress, and may occasionally make backwards-incompatible changes.
Add this to your pom.xml file
<dependency>
<groupId>com.google.gcloud</groupId>
<artifactId>gcloud-java-storage</artifactId>
<version>0.0.10</version>
</dependency>StorageExample is a simple command line interface that provides some of Cloud Storage's functionality. Read more about using the application on the gcloud-java-examples docs page.
See the Authentication section in the base directory's README.
Google Cloud Storage is a durable and highly available object storage service. Google Cloud Storage is almost infinitely scalable and guarantees consistency: when a write succeeds, the latest copy of the object will be returned to any GET, globally.
See the [Google Cloud Storage docs][cloud-storage-activation] for more details on how to activate Cloud Storage for your project.
See the gcloud-java API storage documentation to learn how to interact
with the Cloud Storage using this Client Library.
Here is a code snippet showing a simple usage example from within Compute/App Engine. Note that you must supply credentials and a project ID if running this snippet elsewhere.
import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.gcloud.storage.Blob;
import com.google.gcloud.storage.Storage;
import com.google.gcloud.storage.StorageOptions;
import java.nio.ByteBuffer;
import java.nio.channels.WritableByteChannel;
Storage storage = StorageOptions.getDefaultInstance().service();
Blob blob = new Blob(storage, "bucket", "blob_name");
if (!blob.exists()) {
storage2.create(blob.info(), "Hello, Cloud Storage!".getBytes(UTF_8));
} else {
System.out.println("Updating content for " + blob.info().name());
byte[] prevContent = blob.content();
System.out.println(new String(prevContent, UTF_8));
WritableByteChannel channel = blob.writer();
channel.write(ByteBuffer.wrap("Updated content".getBytes(UTF_8)));
channel.close();
}Java 7 or above is required for using this client.
This library has tools to help make tests for code using Cloud Storage.
See TESTING to read more about testing.
This library follows [Semantic Versioning] (http://semver.org/).
It is currently in major version zero (0.y.z), which means that anything
may change at any time and the public API should not be considered
stable.
Contributions to this library are always welcome and highly encouraged.
See CONTRIBUTING for more information on how to get started.
Apache 2.0 - See LICENSE for more information.