Class S3UploadAction

java.lang.Object
io.inversion.Rule<A>
io.inversion.Action<S3UploadAction>
io.inversion.s3.S3UploadAction
All Implemented Interfaces:
Comparable<S3UploadAction>

public class S3UploadAction extends io.inversion.Action<S3UploadAction>
Sends browser multi-part file uploads to a defined S3 location

Bean 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.

  • Nested Class Summary

    Nested classes/interfaces inherited from class io.inversion.Rule

    io.inversion.Rule.RuleMatcher
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected String
     
    protected long
     
    protected String
     
    protected String
     
    protected String
     
    protected String
     
    protected com.amazonaws.services.s3.AmazonS3
     
    protected String
     
    protected String
     

    Fields inherited from class io.inversion.Rule

    ALL_METHODS, configMap, description, excludeMatchers, excludeOn, includeMatchers, includeOn, log, name, order, params
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    byteToHexString(byte[] input)
     
    com.amazonaws.services.s3.AmazonS3
     
    protected boolean
    isValidPath(io.inversion.utils.Path path)
     
    protected void
    onFileUploaded(io.inversion.Request req, io.inversion.Response resp, io.inversion.Upload upload, io.inversion.s3.S3UploadAction.S3File file)
     
    void
    run(io.inversion.Request req, io.inversion.Response res)
     
    protected io.inversion.s3.S3UploadAction.S3File
    saveFile(io.inversion.Request req, io.inversion.Upload upload)
     
    protected io.inversion.s3.S3UploadAction.S3File
    uploadFile(String bucket, String key, InputStream in, long size)
     
    protected io.inversion.s3.S3UploadAction.S3File
    uploadFile(String bucket, String key, InputStream in, long size, Map<String,String> metadataProps, Map<String,String> tags)
     
    withS3Client(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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • s3AccessKey

      protected String s3AccessKey
    • s3SecretKey

      protected String s3SecretKey
    • s3AwsRegion

      protected String s3AwsRegion
    • s3Bucket

      protected String s3Bucket
    • s3BasePath

      protected String s3BasePath
    • s3DatePath

      protected String s3DatePath
    • maxUploadLength

      protected long maxUploadLength
    • s3Client

      protected com.amazonaws.services.s3.AmazonS3 s3Client
    • allowedCharactersRegex

      protected String allowedCharactersRegex
  • Constructor Details

    • S3UploadAction

      public S3UploadAction()
  • Method Details

    • run

      public void run(io.inversion.Request req, io.inversion.Response res) throws io.inversion.ApiException
      Overrides:
      run in class io.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(String bucket, String key, InputStream in, long size) throws io.inversion.ApiException
      Throws:
      io.inversion.ApiException
    • uploadFile

      protected io.inversion.s3.S3UploadAction.S3File uploadFile(String bucket, String key, InputStream in, long size, Map<String,String> metadataProps, Map<String,String> tags) throws io.inversion.ApiException
      Throws:
      io.inversion.ApiException
    • byteToHexString

      public 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)