jaredramirez/elm-s3/1.0.4

NOTE: the latest version is 1.1.0

S3

This package helps make uploading file to Amazon S3 quick and easy.

Take a look at the README for an example!

Creating a Config

type alias Config =
Config

Opaque configuration type for S3 requests

{ accessKey : String
, secretKey : String
, bucket : String
, region : String
}
-> Config

Create S3 config with the required files common across all requets

withPrefix : String -> Config -> Config

Add a prefix to the file being uploaded. This is helpful to specify a sub directory to upload the file to.

config |> withPrefix "my/sub/dir/"
withSuccessActionStatus : Int -> Config -> Config

Add a cusotm success HTTP status. This defaults to 201.

config |> withSuccessActionStatus 200
withAwsS3Host : String -> Config -> Config

Add a custom S3 host. This defaults to s3.amazonaws.com.

config |> withAwsS3Host "customhost.aws.com"
withAcl : String -> Config -> Config

Add a custom acl (Access Control List) for the uploaded document. This defaults to public-read

config |> withAcl "private"

Uploading a file

type alias FileData =
{ fileName : String
, contentType : String
, file : File
}

All the information needed for a specific file upload.

type alias Response =
{ etag : String
, location : String
, bucket : String
, key : String
}

The response from the upload request.

uploadFile : FileData -> Config -> (Result Error Response -> msg) -> Cmd msg

Upload a file

uploadFileTask : FileData -> Config -> Task Error Response

Upload a file but as a task. This is helpful if you need to upload a file, then get it's location from the Response and send that on your server.