Class AwsS3ServiceImpl
- java.lang.Object
-
- org.craftercms.studio.api.v1.service.aws.AbstractAwsService<org.craftercms.commons.config.profiles.aws.S3Profile>
-
- org.craftercms.studio.impl.v2.service.aws.s3.AwsS3ServiceImpl
-
- All Implemented Interfaces:
AwsS3Service
public class AwsS3ServiceImpl extends AbstractAwsService<org.craftercms.commons.config.profiles.aws.S3Profile> implements AwsS3Service
Default implementation ofAwsS3Service
.- Author:
- joseross
-
-
Field Summary
Fields Modifier and Type Field Description protected org.craftercms.commons.aws.S3ClientCachingFactory
clientFactory
The S3 client factory.protected String
delimiter
The delimiter for S3 pathsstatic String
ITEM_FILTER
protected int
partSize
The part size used for S3 uploadsprotected SiteService
siteService
Instance ofSiteService
protected String
urlPattern
The URL pattern for the generated files-
Fields inherited from class org.craftercms.studio.api.v1.service.aws.AbstractAwsService
profileLoader
-
-
Constructor Summary
Constructors Constructor Description AwsS3ServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
createUrl(String profileId, String key)
protected com.amazonaws.services.s3.AmazonS3
getS3Client(org.craftercms.commons.config.profiles.aws.S3Profile profile)
List<S3Item>
listItems(String siteId, String profileId, String path, String type)
Lists items in an S3 bucket.protected String
normalizePrefix(String prefix)
void
setClientFactory(org.craftercms.commons.aws.S3ClientCachingFactory clientFactory)
void
setDelimiter(String delimiter)
void
setPartSize(int partSize)
void
setSiteService(SiteService siteService)
void
setUrlPattern(String urlPattern)
S3Item
uploadItem(String siteId, String profileId, String path, String filename, InputStream content)
Uploads a file to an S3 bucket.-
Methods inherited from class org.craftercms.studio.api.v1.service.aws.AbstractAwsService
getProfile, setProfileLoader
-
-
-
-
Field Detail
-
ITEM_FILTER
public static final String ITEM_FILTER
- See Also:
- Constant Field Values
-
clientFactory
protected org.craftercms.commons.aws.S3ClientCachingFactory clientFactory
The S3 client factory.
-
partSize
protected int partSize
The part size used for S3 uploads
-
delimiter
protected String delimiter
The delimiter for S3 paths
-
urlPattern
protected String urlPattern
The URL pattern for the generated files
-
siteService
protected SiteService siteService
Instance ofSiteService
-
-
Method Detail
-
setClientFactory
public void setClientFactory(org.craftercms.commons.aws.S3ClientCachingFactory clientFactory)
-
setPartSize
public void setPartSize(int partSize)
-
setDelimiter
public void setDelimiter(String delimiter)
-
setUrlPattern
public void setUrlPattern(String urlPattern)
-
getS3Client
protected com.amazonaws.services.s3.AmazonS3 getS3Client(org.craftercms.commons.config.profiles.aws.S3Profile profile)
-
uploadItem
public S3Item uploadItem(String siteId, String profileId, String path, String filename, InputStream content) throws AwsException, SiteNotFoundException, org.craftercms.commons.config.profiles.ConfigurationProfileNotFoundException
Uploads a file to an S3 bucket.- Specified by:
uploadItem
in interfaceAwsS3Service
- Parameters:
siteId
- the site idprofileId
- the profile idpath
- the path to upload the file (will be used as part of the S3 key)filename
- the filename (will be used as part of the S3 key)content
- a stream providing the content of the file- Returns:
- the uploaded item
- Throws:
AwsException
- if there is any error connection to S3SiteNotFoundException
- if the site is not foundorg.craftercms.commons.config.profiles.ConfigurationProfileNotFoundException
- if the profile is not found
-
listItems
public List<S3Item> listItems(String siteId, String profileId, String path, String type) throws AwsException, SiteNotFoundException, org.craftercms.commons.config.profiles.ConfigurationProfileNotFoundException
Lists items in an S3 bucket.- Specified by:
listItems
in interfaceAwsS3Service
- Parameters:
siteId
- the site idprofileId
- the profile idpath
- the path to listtype
- the type of items to list- Returns:
- the list of items
- Throws:
AwsException
- if there is any error connection to S3SiteNotFoundException
- if the site is not foundorg.craftercms.commons.config.profiles.ConfigurationProfileNotFoundException
- if the profile is not found
-
setSiteService
public void setSiteService(SiteService siteService)
-
-