Created
April 26, 2018 11:06
-
-
Save spradnyesh/47c2d19320639156ebf4b34b924fcda1 to your computer and use it in GitHub Desktop.
accessing aws s3 in clojure using amazonica
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
(ns amazonica-s3.core | |
(:require [amazonica.aws.s3 :as s3] | |
[amazonica.aws.s3transfer :as s3t]) | |
(:gen-class)) | |
(defonce cred {:access-key "" | |
:secret-key "" | |
:endpoint ""}) | |
(defonce bucket "") | |
(defonce static-root "") | |
(defn create-bucket [nm] | |
(s3/create-bucket cred nm)) | |
(defn put-object [path] | |
(let [content (clojure.java.io/file (str static-root path))] | |
(if-not (.exists content) | |
(println path "does not exist") | |
(s3/put-object cred | |
:bucket-name bucket | |
:key path | |
:file content)))) | |
(defn get-object [k] | |
(s3/get-object cred | |
:bucket-name bucket | |
:key k)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment