Pure Elm client for the AWS Simple Storage Service (S3) or Digital Ocean Spaces.
Create a Task to send a signed request over the wire.
Create a Request to list the keys for an S3 bucket.
Read an S3 object.
The contents will be the successful result of the Task created by S3.send.
Read an object and process the entire Http Response.
responseHeaders : Http.Response String -> Result String ( String, List ( String, String ) )
responseHeaders response =
Ok <| ( response.body, Dict.toList response.headers )
getObjectWithHeaders : Bucket -> Key -> Request ( String, List ( String, String ) )
getObjectWithHeaders bucket key =
getFullObject bucket key responseHeadersDo a HEAD request to get only an object's headers.
Read an object with its HTTP response headers.
Write an Html string to S3, with public-read permission.
The string resulting from a successful send isn't interesting.
Write an object to S3, with public-read permission.
The string resulting from a successful send isn't interesting.
Write an object to S3, with default permissions (private).
The string resulting from a successful send isn't interesting.
Delete an S3 object.
The string resulting from a successful send isn't interesting.
Create an HTML body for putObject and friends.
Create a JSON body for putObject and friends.
Create a body with any mimetype for putObject and friends.
stringBody "text/html" "Hello, World!"Add query parameters to a Request.
Add headers to a Request.
Read JSON from a URL and turn it into a list of Accounts.
If Nothing is passed for the first arg (the URL), will use the default of "accounts.json".
You're not going to want to store the secret keys in this JSON in plain text anywhere but your development machine. I'll add support eventually for encryption of the accounts JSON.
Example JSON (the buckets are used only by the example code):
[{"name": "Digital Ocean",
"region": "nyc3",
"is-digital-ocean": true,
"access-key": "<20-character access key>",
"secret-key": "<40-character secret key>",
"buckets": ["bucket1","bucket2"]
},
{"name": "Amazon S3",
"region": "us-east-1",
"access-key": "<20-character access key>",
"secret-key": "<40-character secret key>",
"buckets": ["bucket3","bucket4","bucket5"]
}
]Decode a JSON string encoding a list of Accounts
A Decoder for the Account type.
Turn a bucket and a key into an object path.
"/" ++ bucket ++ "/" ++ keyLow-level request creator.
stringRequest : Method -> String -> Body -> Request String String
stringRequest method url body =
parserRequest
method
url
body
requestBodyResult
Task.succeedCreate a Request that returns its response body as a string.
getObject : Bucket -> Key -> Request String String
getObject bucket key =
stringRequest GET (objectPath bucket key) emptyBodyA parser for parserRequest that pulls the body out of the response as a string.
A request that can be turned into a Task by
S3.send.bis an internal type that you will never care about.ais the type of the successfulTaskresult fromS3.send.