Class S3UploadAction
- java.lang.Object
-
- io.inversion.Rule<A>
-
- io.inversion.Action<S3UploadAction>
-
- io.inversion.s3.S3UploadAction
-
- All Implemented Interfaces:
java.lang.Comparable<S3UploadAction>
public class S3UploadAction extends io.inversion.Action<S3UploadAction>
Sends browser multi-part file uploads to a defined S3 locationBean property config can be set directly on the handler in your inversion.properties files but you should really consider this to be a service singleton where the properties can be passed in via Action config allowing a single handler instance to upload files to multiple buckets based on request path.
So instead of config-ing something like
handler.dynamicBasePath=yyyy/MM/dd or handler.bucket=somebucket
do this
action.config=dynamicBasePath=yyyy/MM/dd@amp;bucket=somebucket
While accessKey/secreKey/awsRegion CAN be set either on the Handler or on the Action in this way, if you control the host environment and are uploading everyting to your own AWS account, you should consider using IAM roles to authenticate. Than way you don't need to config the credentials at all.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringallowedCharactersRegexprotected longmaxUploadLengthprotected java.lang.Strings3AccessKeyprotected java.lang.Strings3AwsRegionprotected java.lang.Strings3BasePathprotected java.lang.Strings3Bucketprotected com.amazonaws.services.s3.AmazonS3s3Clientprotected java.lang.Strings3DatePathprotected java.lang.Strings3SecretKey
-
Constructor Summary
Constructors Constructor Description S3UploadAction()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringbyteToHexString(byte[] input)com.amazonaws.services.s3.AmazonS3getS3Client()protected booleanisValidPath(io.inversion.utils.Path path)protected voidonFileUploaded(io.inversion.Request req, io.inversion.Response resp, io.inversion.Upload upload, io.inversion.s3.S3UploadAction.S3File file)voidrun(io.inversion.Request req, io.inversion.Response res)protected io.inversion.s3.S3UploadAction.S3FilesaveFile(io.inversion.Request req, io.inversion.Upload upload)protected io.inversion.s3.S3UploadAction.S3FileuploadFile(java.lang.String bucket, java.lang.String key, java.io.InputStream in, long size)protected io.inversion.s3.S3UploadAction.S3FileuploadFile(java.lang.String bucket, java.lang.String key, java.io.InputStream in, long size, java.util.Map<java.lang.String,java.lang.String> metadataProps, java.util.Map<java.lang.String,java.lang.String> tags)S3UploadActionwithS3Client(com.amazonaws.services.s3.AmazonS3 s3Client)-
Methods inherited from class io.inversion.Action
configureOp, doDelete, doGet, doPatch, doPost, doPut, getFullIncludePaths, getIncludePaths, isDecoration, joinPaths, joinPaths0, run0, withDecoration
-
Methods inherited from class io.inversion.Rule
afterWiringComplete, checkLazyConfig, compareTo, doLazyConfig, getAllExcludePaths, getAllIncludeMethods, getAllIncludePaths, getDefaultIncludeMatchers, getDescription, getExcludeMatchers, getIncludeMatchers, getName, getOrder, getParams, match, match, matches, matches, toString, withDescription, withExcludeOn, withExcludeOn, withIncludeOn, withIncludeOn, withName, withOrder, withParam, withParams
-
-
-
-
Field Detail
-
s3AccessKey
protected java.lang.String s3AccessKey
-
s3SecretKey
protected java.lang.String s3SecretKey
-
s3AwsRegion
protected java.lang.String s3AwsRegion
-
s3Bucket
protected java.lang.String s3Bucket
-
s3BasePath
protected java.lang.String s3BasePath
-
s3DatePath
protected java.lang.String s3DatePath
-
maxUploadLength
protected long maxUploadLength
-
s3Client
protected com.amazonaws.services.s3.AmazonS3 s3Client
-
allowedCharactersRegex
protected java.lang.String allowedCharactersRegex
-
-
Method Detail
-
run
public void run(io.inversion.Request req, io.inversion.Response res) throws io.inversion.ApiException- Overrides:
runin classio.inversion.Action<S3UploadAction>- Throws:
io.inversion.ApiException
-
onFileUploaded
protected void onFileUploaded(io.inversion.Request req, io.inversion.Response resp, io.inversion.Upload upload, io.inversion.s3.S3UploadAction.S3File file)
-
saveFile
protected io.inversion.s3.S3UploadAction.S3File saveFile(io.inversion.Request req, io.inversion.Upload upload) throws io.inversion.ApiException- Throws:
io.inversion.ApiException
-
uploadFile
protected io.inversion.s3.S3UploadAction.S3File uploadFile(java.lang.String bucket, java.lang.String key, java.io.InputStream in, long size) throws io.inversion.ApiException- Throws:
io.inversion.ApiException
-
uploadFile
protected io.inversion.s3.S3UploadAction.S3File uploadFile(java.lang.String bucket, java.lang.String key, java.io.InputStream in, long size, java.util.Map<java.lang.String,java.lang.String> metadataProps, java.util.Map<java.lang.String,java.lang.String> tags) throws io.inversion.ApiException- Throws:
io.inversion.ApiException
-
byteToHexString
public java.lang.String byteToHexString(byte[] input)
-
isValidPath
protected boolean isValidPath(io.inversion.utils.Path path)
-
getS3Client
public com.amazonaws.services.s3.AmazonS3 getS3Client()
-
withS3Client
public S3UploadAction withS3Client(com.amazonaws.services.s3.AmazonS3 s3Client)
-
-