Package org.dspace.storage.bitstore
Class S3BitStoreService
- java.lang.Object
-
- org.dspace.storage.bitstore.S3BitStoreService
-
- All Implemented Interfaces:
BitStoreService
public class S3BitStoreService extends Object implements BitStoreService
Asset store using Amazon's Simple Storage Service (S3). S3 is a commercial, web-service accessible, remote storage facility. NB: you must have obtained an account with Amazon to use this store- Author:
- Richard Rodgers, Peter Dietz
-
-
Constructor Summary
Constructors Constructor Description S3BitStoreService()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Mapabout(Bitstream bitstream, Map attrs)Obtain technical metadata about an asset in the asset store.StringgenerateId()Return an identifier unique to this asset store instanceInputStreamget(Bitstream bitstream)Retrieve the bits for the asset with ID.StringgetAwsAccessKey()StringgetAwsRegionName()StringgetAwsSecretKey()StringgetBucketName()StringgetFullKey(String id)Utility Method: Prefix the key with a subfolder, if this instance assets are stored within subfolderStringgetSubfolder()voidinit()Initialize the asset store S3 Requires: - access key - secret key - bucket namestatic voidmain(String[] args)Contains a command-line testing tool.voidput(Bitstream bitstream, InputStream in)Store a stream of bits.voidremove(Bitstream bitstream)Remove an asset from the asset store.voidsetAwsAccessKey(String awsAccessKey)voidsetAwsRegionName(String awsRegionName)voidsetAwsSecretKey(String awsSecretKey)voidsetBucketName(String bucketName)voidsetSubfolder(String subfolder)
-
-
-
Method Detail
-
init
public void init() throws IOExceptionInitialize the asset store S3 Requires: - access key - secret key - bucket name- Specified by:
initin interfaceBitStoreService- Throws:
IOException- A general class of exceptions produced by failed or interrupted I/O operations.
-
generateId
public String generateId()
Return an identifier unique to this asset store instance- Specified by:
generateIdin interfaceBitStoreService- Returns:
- a unique ID
-
get
public InputStream get(Bitstream bitstream) throws IOException
Retrieve the bits for the asset with ID. If the asset does not exist, returns null.- Specified by:
getin interfaceBitStoreService- Parameters:
bitstream- The ID of the asset to retrieve- Returns:
- The stream of bits, or null
- Throws:
IOException- If a problem occurs while retrieving the bits
-
put
public void put(Bitstream bitstream, InputStream in) throws IOException
Store a stream of bits.If this method returns successfully, the bits have been stored. If an exception is thrown, the bits have not been stored.
- Specified by:
putin interfaceBitStoreService- Parameters:
in- The stream of bits to storebitstream- The bitstream object- Throws:
IOException- If a problem occurs while storing the bits
-
about
public Map about(Bitstream bitstream, Map attrs) throws IOException
Obtain technical metadata about an asset in the asset store. Checksum used is (ETag) hex encoded 128-bit MD5 digest of an object's content as calculated by Amazon S3 (Does not use getContentMD5, as that is 128-bit MD5 digest calculated on caller's side)- Specified by:
aboutin interfaceBitStoreService- Parameters:
bitstream- The asset to describeattrs- A Map whose keys consist of desired metadata fields- Returns:
- attrs A Map with key/value pairs of desired metadata If file not found, then return null
- Throws:
IOException- If a problem occurs while obtaining metadata
-
remove
public void remove(Bitstream bitstream) throws IOException
Remove an asset from the asset store. An irreversible operation.- Specified by:
removein interfaceBitStoreService- Parameters:
bitstream- The asset to delete- Throws:
IOException- If a problem occurs while removing the asset
-
getFullKey
public String getFullKey(String id)
Utility Method: Prefix the key with a subfolder, if this instance assets are stored within subfolder- Parameters:
id- DSpace bitstream internal ID- Returns:
- full key prefixed with a subfolder, if applicable
-
getAwsAccessKey
public String getAwsAccessKey()
-
setAwsAccessKey
@Autowired(required=true) public void setAwsAccessKey(String awsAccessKey)
-
getAwsSecretKey
public String getAwsSecretKey()
-
setAwsSecretKey
@Autowired(required=true) public void setAwsSecretKey(String awsSecretKey)
-
getAwsRegionName
public String getAwsRegionName()
-
setAwsRegionName
public void setAwsRegionName(String awsRegionName)
-
getBucketName
@Autowired(required=true) public String getBucketName()
-
setBucketName
public void setBucketName(String bucketName)
-
getSubfolder
public String getSubfolder()
-
setSubfolder
public void setSubfolder(String subfolder)
-
-