Skip to content

Instantly share code, notes, and snippets.

@spradnyesh
Created April 26, 2018 11:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spradnyesh/47c2d19320639156ebf4b34b924fcda1 to your computer and use it in GitHub Desktop.
Save spradnyesh/47c2d19320639156ebf4b34b924fcda1 to your computer and use it in GitHub Desktop.
accessing aws s3 in clojure using amazonica
(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