1. Setup your project to include filesystem
    • Get the dependency org.apache.jclouds.api/filesystem using jclouds Installation.
  2. Start coding
// setup where the provider must store the files
Properties properties = new Properties();
properties.setProperty(FilesystemConstants.PROPERTY_BASEDIR, "./local/filesystemstorage");
// setup the container name used by the provider (like bucket in S3)
String containerName = "test-container";

// get a context with filesystem that offers the portable BlobStore api
BlobStoreContext context = ContextBuilder.newBuilder("filesystem")
                 .overrides(properties)
                 .buildView(BlobStoreContext.class);

// create a container in the default location
BlobStore blobStore = context.getBlobStore();
blobStore.createContainerInLocation(null, containerName);

// add blob
Blob blob = blobStore.newBlob("test");
blob.setPayload("test data");
blobStore.putBlob(containerName, blob);

// retrieve blob
Blob blobRetrieved = blobStore.getBlob(containerName, "test");

// delete blob
blobStore.removeBlob(containerName, "test");

//close context
context.close();

Tips & tricks