BlobContainerpublic class FsBlobContainer extends AbstractBlobContainer
BlobContainer.
All blobs in the container are stored on a file system, the location of which is specified by the BlobPath.
Note that the methods in this implementation of BlobContainer may
additionally throw a SecurityException if the configured SecurityManager
does not permit read and/or write access to the underlying files.| Modifier and Type | Field | Description |
|---|---|---|
protected FsBlobStore |
blobStore |
|
protected java.nio.file.Path |
path |
| Constructor | Description |
|---|---|
FsBlobContainer(FsBlobStore blobStore,
BlobPath blobPath,
java.nio.file.Path path) |
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
blobExists(java.lang.String blobName) |
Tests whether a blob with the given blob name exists in the container.
|
void |
deleteBlob(java.lang.String blobName) |
Deletes a blob with giving name, if the blob exists.
|
java.util.Map<java.lang.String,BlobMetaData> |
listBlobs() |
Lists all blobs in the container.
|
java.util.Map<java.lang.String,BlobMetaData> |
listBlobsByPrefix(java.lang.String blobNamePrefix) |
Lists all blobs in the container that match the specified prefix.
|
void |
move(java.lang.String source,
java.lang.String target) |
Renames the source blob into the target blob.
|
java.io.InputStream |
readBlob(java.lang.String name) |
Creates a new
InputStream for the given blob name. |
void |
writeBlob(java.lang.String blobName,
java.io.InputStream inputStream,
long blobSize) |
Reads blob content from the input stream and writes it to the container in a new blob with the given name.
|
pathprotected final FsBlobStore blobStore
protected final java.nio.file.Path path
public FsBlobContainer(FsBlobStore blobStore, BlobPath blobPath, java.nio.file.Path path)
public java.util.Map<java.lang.String,BlobMetaData> listBlobs() throws java.io.IOException
BlobContainerBlobMetaData, containing basic information about each blob.java.io.IOException - if there were any failures in reading from the blob container.public java.util.Map<java.lang.String,BlobMetaData> listBlobsByPrefix(java.lang.String blobNamePrefix) throws java.io.IOException
BlobContainerblobNamePrefix - The prefix to match against blob names in the container.BlobMetaData, containing basic information about each blob.java.io.IOException - if there were any failures in reading from the blob container.public void deleteBlob(java.lang.String blobName)
throws java.io.IOException
BlobContainerblobName - The name of the blob to delete.java.nio.file.NoSuchFileException - if the blob does not existjava.io.IOException - if the blob exists but could not be deleted.public boolean blobExists(java.lang.String blobName)
BlobContainerblobName - The name of the blob whose existence is to be determined.true if a blob exists in the BlobContainer with the given name, and false otherwise.public java.io.InputStream readBlob(java.lang.String name)
throws java.io.IOException
BlobContainerInputStream for the given blob name.name - The name of the blob to get an InputStream for.InputStream to read the blob.java.nio.file.NoSuchFileException - if the blob does not existjava.io.IOException - if the blob can not be read.public void writeBlob(java.lang.String blobName,
java.io.InputStream inputStream,
long blobSize)
throws java.io.IOException
BlobContainerIOException will be thrown.blobName - The name of the blob to write the contents of the input stream to.inputStream - The input stream from which to retrieve the bytes to write to the blob.blobSize - The size of the blob to be written, in bytes. It is implementation dependent whether
this value is used in writing the blob to the repository.java.nio.file.FileAlreadyExistsException - if a blob by the same name already existsjava.io.IOException - if the input stream could not be read, or the target blob could not be written to.public void move(java.lang.String source,
java.lang.String target)
throws java.io.IOException
BlobContainerBlobContainer for which atomicity can be guaranteed is the
FsBlobContainer.source - The blob to rename.target - The name of the blob after the renaming.java.io.IOException - if the source blob does not exist, the target blob already exists,
or there were any failures in reading from the blob container.