Package io.nitric.api.storage
Class File
- java.lang.Object
-
- io.nitric.api.storage.File
-
public class File extends Object
Provides a Storage API bucket class.
The example below illustrates the Storage API.
import io.nitric.api.storage.Storage; ... byte[] frontData = ... // Store an file file Storage.bucket("inspection-images") .file("582764-front-elevation.jpg") .write(frontData); // Retrieve an image file byte[] sideData = Storage.bucket("inspection-images") .file("582764-side-elevation.jpg") .read(); // Delete an image file Storage.bucket(bucket) .file("582764-rear-elevation.jpg") .delete();
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
delete()
Delete an item from a bucket with the given key if it exists.String
getBucket()
Return the storage bucket name.String
getKey()
Return the storage file key.byte[]
read()
Retrieve an item from a bucket with the given key if it exists.String
toString()
Return the string representation of this object.void
write(byte[] data)
Store an item to a bucket with the given key.
-
-
-
Method Detail
-
getBucket
public String getBucket()
Return the storage bucket name.- Returns:
- the bucket name
-
getKey
public String getKey()
Return the storage file key.- Returns:
- the file key
-
read
public byte[] read()
Retrieve an item from a bucket with the given key if it exists.- Returns:
- the storage item data is it exists, or null otherwise
-
write
public void write(byte[] data)
Store an item to a bucket with the given key. This operation will perform a create or update depending upon whether an item already exists in the bucket for the given key.- Parameters:
data
- the item data
-
delete
public void delete()
Delete an item from a bucket with the given key if it exists.
-
-