Last active
August 31, 2015 18:19
-
-
Save ybur-yug/3005a69e257968319adf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule NuntiusOpera.Mixfile do | |
| use Mix.Project | |
| def project do | |
| [app: :nuntius_opera, | |
| version: "0.0.1", | |
| elixir: "~> 1.0", | |
| build_embedded: Mix.env == :prod, | |
| start_permanent: Mix.env == :prod, | |
| deps: deps] | |
| end | |
| def application do | |
| [applications: [:logger, :ssl, :erlcloud], | |
| mod: {NuntiusOpera, []}] | |
| end | |
| defp deps do | |
| [ | |
| {:erlcloud, "~> 0.9.2"} | |
| ] | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule NuntiusOpera.Worker do | |
| def setup_aws do | |
| aws_access = System.get_env("AWS_ACCESS_KEY_ID") |> String.to_char_list | |
| aws_secret = System.get_env("AWS_SECRET_ACCESS_KEY") |> String.to_char_list | |
| # char list because elixir doesnt like strings, in the normal form | |
| :erlcloud_s3.configure(aws_access, aws_secret) | |
| end | |
| def create_bucket(name) do | |
| setup_aws | |
| :erlcloud_s3.create_bucket(name) | |
| end | |
| def set(bucket, k, v) do | |
| setup_aws | |
| :ercloud_s3.put_object(bucket, k, v) | |
| end | |
| def get(bucket, k) do | |
| setup_aws | |
| :erlcloud_s3.get_object(bucket, k)[:content] | |
| end | |
| def ls_keys(bucket) do | |
| setup_aws | |
| objs = :erlcloud_s3.list_objects(bucket) | |
| for obj <- objs[:contents], do: obj[:key] | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment