s3sdk

Class AmazonS3

lucee.Component
    extended by s3sdk.AmazonS3

Amazon S3 REST Wrapper

Class Attributes:
  • singleton
  •  
  • output : false
  •  
  • synchronized : false
  •  
  • accessors : true
  •  
  • persistent : false
  •  
    Property Summary
    type property default serializable required
    any accessKey


    • access = public
    • returntype = any
    true false
    any encryption_charset


    • access = public
    • returntype = any
    true false
    any log


    • access = public
    • returntype = any
    • inject = logbox:logger:{this}
    true false
    any secretKey


    • access = public
    • returntype = any
    true false
    any ssl


    • access = public
    • returntype = any
    true false
    any URLEndPoint


    • access = public
    • returntype = any
    true false
    Constructor Summary
    init(any accessKey, any secretKey, [any encryption_charset='utf-8'], [any ssl='false'])
          Constructor.
    Method Summary
    boolean copyObject(string fromBucket, string fromURI, string toBucket, string toURI, [string acl='[runtime expression]'], [struct metaHeaders='[runtime expression]'])
         Copies an object.
    struct createMetaHeaders([struct metaHeaders='[runtime expression]'])
         Create a structure of amazon enabled metadata headers.
    any createSignature(any stringToSign)
         Create request signature according to AWS standards.
    boolean deleteBucket(string bucketName)
         Deletes a bucket.
    boolean deleteObject(string bucketName, string uri)
         Deletes an object.
    string getAccessKey()
    array getAcessControlPolicy(string bucketName, [string uri=''])
         Get's a bucket or object's ACL policy'.
    string getAuthenticatedURL(string bucketName, string uri, [string minutesValid='60'], [boolean virtualHostStyle='false'], [boolean useSSL='false'])
         Returns a query string authenticated URL to an object in S3.
    array getBucket(string bucketName, [string prefix=''], [string marker=''], [string maxKeys=''], [string delimiter=''])
         Lists information about the objects of a bucket.
    string getBucketLocation(string bucketName)
         Get bucket location.
    string getBucketVersionStatus(string bucketName)
         Get bucket location.
    string getEncryption_charset()
    string getLog()
    struct getObjectInfo(string bucketName, string uri)
         Get an object's metadata information.
    string getSecretKey()
    string getSsl()
    string getURLEndPoint()
    private binary HMAC_SHA1(string signKey, string signMessage)
         NSA SHA-1 Algorithm: RFC 2104HMAC-SHA1 .
    array listBuckets()
         List all available buckets.
    boolean putBucket(string bucketName, [string acl='[runtime expression]'], [string location='USA'])
         Creates a bucket.
    string putObject(string bucketName, string uri, [any data=''], [string contentDisposition=''], [string contentType='text/plain'], [numeric HTTPTimeout='300'], [string cacheControl='no-store, no-cache, must-revalidate'], [string expires=''], [string acl='[runtime expression]'], [struct metaHeaders='[runtime expression]'])
         Puts an object into a bucket and returns the etag.
    string putObjectFile(string bucketName, string filepath, [string uri=''], [string contentType='binary/octet-stream'], [numeric HTTPTimeout='300'], [string cacheControl='no-store, no-cache, must-revalidate'], [string expires=''], [string acl='[runtime expression]'], [struct metaHeaders='[runtime expression]'])
         Puts an object from a local file into a bucket and returns the etag.
    string putObjectFolder(string bucketName, string uri='', [string contentType='binary/octet-stream'], [numeric HTTPTimeout='300'], [string cacheControl='no-store, no-cache, must-revalidate'], [string expires=''], [string acl='[runtime expression]'], [struct metaHeaders='[runtime expression]'])
         Puts an object from a local file into a bucket and returns the etag.
    boolean renameObject(string oldBucketName, string oldFileKey, string newBucketName, string newFileKey)
         Renames an object by copying then deleting original.
    private struct S3Request([string method='GET'], [string resource=''], [any body=''], [struct headers='[runtime expression]'], [struct amzHeaders='[runtime expression]'], [struct parameters='[runtime expression]'], [numeric timeout='20'])
         Invoke an Amazon REST Call.
    any setAccessKey(any accessKey)
    void setAuth(string accessKey='', string secretKey='')
         Set the Amazon credentials.
    boolean setBucketVersionStatus(string bucketName, [boolean version='true'])
         set bucket versioning.
    any setEncryption_charset(any encryption_charset)
    any setLog(any log)
    any setSecretKey(any secretKey)
    void setSSL([boolean useSSL='true'])
         Set SSL flag and alter the internal URL End point pointer.
    any setURLEndPoint(any URLEndPoint)
     
    Methods inherited from class lucee.Component
    None

    Constructor Detail

    init

    public init(any accessKey, any secretKey, [any encryption_charset='utf-8'], [any ssl='false'])

    Constructor

    Parameters:
    accessKey
    secretKey
    encryption_charset
    ssl

    Property Detail

    accessKey

    property any accessKey

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    encryption_charset

    property any encryption_charset

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    log

    property any log

    Attributes:
    access - public
    required - false
    returntype - any
    inject - logbox:logger:{this}
    serializable - true

    secretKey

    property any secretKey

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    ssl

    property any ssl

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    URLEndPoint

    property any URLEndPoint

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    Method Detail

    copyObject

    public boolean copyObject(string fromBucket, string fromURI, string toBucket, string toURI, [string acl='[runtime expression]'], [struct metaHeaders='[runtime expression]'])

    Copies an object. False if the same object or error copying object.

    Parameters:
    fromBucket - The source bucket
    fromURI - The source uri
    toBucket - The destination bucket
    toURI - The destination uri
    acl - The default Amazon security access policy
    metaHeaders - Replace metadata headers to the file by passing a struct of name-value pairs

    createMetaHeaders

    public struct createMetaHeaders([struct metaHeaders='[runtime expression]'])

    Create a structure of amazon enabled metadata headers

    Parameters:
    metaHeaders - Add additonal metadata headers to the file by passing a struct of name-value pairs

    createSignature

    public any createSignature(any stringToSign)

    Create request signature according to AWS standards

    Parameters:
    stringToSign

    deleteBucket

    public boolean deleteBucket(string bucketName)

    Deletes a bucket.

    Parameters:
    bucketName

    deleteObject

    public boolean deleteObject(string bucketName, string uri)

    Deletes an object.

    Parameters:
    bucketName - The bucket name
    uri - The file object uri to remove

    getAccessKey

    public string getAccessKey()


    getAcessControlPolicy

    public array getAcessControlPolicy(string bucketName, [string uri=''])

    Get's a bucket or object's ACL policy'

    Parameters:
    bucketName - The bucket name to list
    uri - The object URI to get the policy

    getAuthenticatedURL

    public string getAuthenticatedURL(string bucketName, string uri, [string minutesValid='60'], [boolean virtualHostStyle='false'], [boolean useSSL='false'])

    Returns a query string authenticated URL to an object in S3.

    Parameters:
    bucketName - The bucket the object resides in
    uri - The uri to the object to create a link for
    minutesValid - The minutes the link is valid for. Defaults to 60 minutes
    virtualHostStyle - Whether to use virtual bucket style or path style. Defaults to virtual
    useSSL - Use SSL on http call

    getBucket

    public array getBucket(string bucketName, [string prefix=''], [string marker=''], [string maxKeys=''], [string delimiter=''])

    Lists information about the objects of a bucket

    Parameters:
    bucketName - The bucket name to list
    prefix - Limits the response to keys which begin with the indicated prefix.
    marker - Indicates where in the bucket to begin listing.
    maxKeys - The maximum number of keys you'd like to see in the response body
    delimiter - The delimiter to use in the keys

    getBucketLocation

    public string getBucketLocation(string bucketName)

    Get bucket location.

    Parameters:
    bucketName - The bucket name to get info on

    getBucketVersionStatus

    public string getBucketVersionStatus(string bucketName)

    Get bucket location.

    Parameters:
    bucketName - The bucket name to get info on

    getEncryption_charset

    public string getEncryption_charset()


    getLog

    public string getLog()


    getObjectInfo

    public struct getObjectInfo(string bucketName, string uri)

    Get an object's metadata information

    Parameters:
    bucketName - The bucket the object resides in
    uri - The object URI to retrieve info from

    getSecretKey

    public string getSecretKey()


    getSsl

    public string getSsl()


    getURLEndPoint

    public string getURLEndPoint()


    HMAC_SHA1

    private binary HMAC_SHA1(string signKey, string signMessage)

    NSA SHA-1 Algorithm: RFC 2104HMAC-SHA1

    Parameters:
    signKey
    signMessage

    listBuckets

    public array listBuckets()

    List all available buckets.


    putBucket

    public boolean putBucket(string bucketName, [string acl='[runtime expression]'], [string location='USA'])

    Creates a bucket

    Parameters:
    bucketName - The name of the bucket to create
    acl - The ACL permissions to apply. Use the this scope constants for ease of use.
    location - The location of the storage, defaults to USA or EU

    putObject

    public string putObject(string bucketName, string uri, [any data=''], [string contentDisposition=''], [string contentType='text/plain'], [numeric HTTPTimeout='300'], [string cacheControl='no-store, no-cache, must-revalidate'], [string expires=''], [string acl='[runtime expression]'], [struct metaHeaders='[runtime expression]'])

    Puts an object into a bucket and returns the etag

    Parameters:
    bucketName - The bucket to store in
    uri - The destination uri key to use when saving the object
    data - The content to save as data, this can be binary,string or anything you like.
    contentDisposition - The content-disposition header to use when downloading file
    contentType - The file/data content type, defaults to text/plain. For plain binary use: binary/octet-stream
    HTTPTimeout - The HTTP timeout to use
    cacheControl - The caching header to send. Defaults to no caching. Example: public,max-age=864000 (10days). For more info look here: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9
    expires - Sets the expiration header of the object in days.
    acl - The default Amazon security access policy
    metaHeaders - Add additonal metadata headers to the file by passing a struct of name-value pairs

    putObjectFile

    public string putObjectFile(string bucketName, string filepath, [string uri=''], [string contentType='binary/octet-stream'], [numeric HTTPTimeout='300'], [string cacheControl='no-store, no-cache, must-revalidate'], [string expires=''], [string acl='[runtime expression]'], [struct metaHeaders='[runtime expression]'])

    Puts an object from a local file into a bucket and returns the etag

    Parameters:
    bucketName - The bucket to store in
    filepath - The absolute file path to read in binary and upload
    uri - The destination uri key to use when saving the object, if not used, the name of the file will be used.
    contentType - The file content type, defaults to: binary/octet-stream
    HTTPTimeout - The HTTP timeout to use
    cacheControl - The caching header to send. Defaults to no caching. Example: public,max-age=864000 (10days). For more info look here: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9
    expires - Sets the expiration header of the object in days.
    acl - The default Amazon security access policy
    metaHeaders - Add additonal metadata headers to the file by passing a struct of name-value pairs

    putObjectFolder

    public string putObjectFolder(string bucketName, string uri='', [string contentType='binary/octet-stream'], [numeric HTTPTimeout='300'], [string cacheControl='no-store, no-cache, must-revalidate'], [string expires=''], [string acl='[runtime expression]'], [struct metaHeaders='[runtime expression]'])

    Puts an object from a local file into a bucket and returns the etag

    Parameters:
    bucketName - The bucket to store in
    uri - The destination uri key to use when saving the object, if not used, the name of the file will be used.
    contentType - The file content type, defaults to: binary/octet-stream
    HTTPTimeout - The HTTP timeout to use
    cacheControl - The caching header to send. Defaults to no caching. Example: public,max-age=864000 (10days). For more info look here: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9
    expires - Sets the expiration header of the object in days.
    acl - The default Amazon security access policy
    metaHeaders - Add additonal metadata headers to the file by passing a struct of name-value pairs

    renameObject

    public boolean renameObject(string oldBucketName, string oldFileKey, string newBucketName, string newFileKey)

    Renames an object by copying then deleting original.

    Parameters:
    oldBucketName
    oldFileKey
    newBucketName
    newFileKey

    S3Request

    private struct S3Request([string method='GET'], [string resource=''], [any body=''], [struct headers='[runtime expression]'], [struct amzHeaders='[runtime expression]'], [struct parameters='[runtime expression]'], [numeric timeout='20'])

    Invoke an Amazon REST Call

    Parameters:
    method - The HTTP method to invoke
    resource - The resource to hit in the amazon s3 service.
    body - The body content of the request if passed.
    headers - An struct of HTTP headers to send
    amzHeaders - An struct of amz header name-value pairs to send
    parameters - An struct of HTTP URL parameters to send in the request
    timeout - The default call timeout

    setAccessKey

    public any setAccessKey(any accessKey)

    Parameters:
    accessKey

    setAuth

    public void setAuth(string accessKey='', string secretKey='')

    Set the Amazon credentials

    Parameters:
    accessKey - The amazon access key
    secretKey - The amazon secret key

    setBucketVersionStatus

    public boolean setBucketVersionStatus(string bucketName, [boolean version='true'])

    set bucket versioning

    Parameters:
    bucketName - The name of the bucket to create
    version - the version status enabled/disabled.

    setEncryption_charset

    public any setEncryption_charset(any encryption_charset)

    Parameters:
    encryption_charset

    setLog

    public any setLog(any log)

    Parameters:
    log

    setSecretKey

    public any setSecretKey(any secretKey)

    Parameters:
    secretKey

    setSSL

    public void setSSL([boolean useSSL='true'])

    Set SSL flag and alter the internal URL End point pointer

    Parameters:
    useSSL - Set to true or false

    setURLEndPoint

    public any setURLEndPoint(any URLEndPoint)

    Parameters:
    URLEndPoint