public class Project
extends java.lang.Object
implements java.lang.AutoCloseable
Make sure to always close the Project object after completing work with it. The Project class
implements the AutoCloseable
interface, so it is best to use Project objects
in try-with-resource blocks:
try (Project project = uplink.openProject(access)) {
Bucket bucket = project.createBucket("my-bucket")) {
...
}
}
Modifier and Type | Method and Description |
---|---|
void |
close() |
BucketInfo |
createBucket(java.lang.String bucket)
Creates a bucket in this project.
|
BucketInfo |
deleteBucket(java.lang.String bucket)
Deletes an bucket from this project.
|
ObjectInfo |
deleteObject(java.lang.String bucket,
java.lang.String key)
Deletes an object from this bucket.
|
ObjectInputStream |
downloadObject(java.lang.String bucket,
java.lang.String key,
ObjectDownloadOption... options)
Starts a download from the specific key.
|
BucketInfo |
ensureBucket(java.lang.String bucket)
Ensures that a bucket exists in this project.
|
BucketIterator |
listBuckets(BucketListOption... options) |
ObjectIterator |
listObjects(java.lang.String bucket,
ObjectListOption... options)
Lists the objects in this bucket.
|
BucketInfo |
statBucket(java.lang.String bucket)
Returns bucket metadata.
|
ObjectInfo |
statObject(java.lang.String bucket,
java.lang.String key)
Returns object metadata.
|
ObjectOutputStream |
uploadObject(java.lang.String bucket,
java.lang.String key,
ObjectUploadOption... options)
Uploads the content to a new object in this bucket.
|
public BucketInfo statBucket(java.lang.String bucket) throws StorjException
bucket
- the bucket nameStorjException
- if an error occurs during the deletionpublic BucketInfo createBucket(java.lang.String bucket) throws StorjException
bucket
- the bucket nameStorjException
- if an error occurs during the deletionpublic BucketInfo ensureBucket(java.lang.String bucket) throws StorjException
bucket
- the bucket nameStorjException
- if an error occurs during the deletionpublic BucketIterator listBuckets(BucketListOption... options)
public BucketInfo deleteBucket(java.lang.String bucket) throws StorjException
bucket
- the bucket nameStorjException
- if an error occurs during the deletionpublic ObjectInfo statObject(java.lang.String bucket, java.lang.String key) throws StorjException
bucket
- the bucket namekey
- the key of the object to deleteStorjException
- if an error occurs during the deletionpublic ObjectInfo deleteObject(java.lang.String bucket, java.lang.String key) throws StorjException
bucket
- the bucket namekey
- the key of the object to deleteStorjException
- if an error occurs during the deletionpublic ObjectOutputStream uploadObject(java.lang.String bucket, java.lang.String key, ObjectUploadOption... options) throws StorjException
bucket
- the bucket namekey
- an object keyoptions
- options to apply on the new objectStorjException
- if an error occurs during the uploadpublic ObjectInputStream downloadObject(java.lang.String bucket, java.lang.String key, ObjectDownloadOption... options) throws StorjException
bucket
- the bucket namekey
- an object keyoptions
- options to apply while downloadingStorjException
- if an error occurs during the downloadpublic ObjectIterator listObjects(java.lang.String bucket, ObjectListOption... options)
bucket
- the bucket nameoptions
- an optional list of ObjectListOption
Iterable
<ObjectInfo
>public void close() throws StorjException
close
in interface java.lang.AutoCloseable
StorjException