Skip to content

benhowell/s3-crewser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 

Repository files navigation

s3-crewser

AWS s3 upload, list and delete recipe for clojure web apps.

Small server-side wrapper for amazonica and s3-beam for uploading, listing and deleting files from your clojure(script) web app. The main reason to use both s3-beam and amazonica in the same implementation is to leverage s3-beam to perform direct from browser uploading of files to s3 (therefore saving any server-side handling of those files) and to leverage amazonica for everything else (and again, not have to do any server-side handling of the actual files).

Note: This is a bare bones recipe and the amazonica library has much more functionality than what's demonstrated here.

Requires:

Server-side config

Wherever you define your routes, add a path for "/sign" like so:

(defroutes

  ;; aws s3-beam
   (GET "/sign" {params :params} (aws-s3/s3-sign))
  ;; end aws s3-beam

)

Server-side usage

List objects like so:

(ns server.some.namespace
  (:require
   [server.controllers.aws.s3 :as aws-s3]))
   
(aws-s3/list-objects)

Delete an object like so:

(ns server.some.namespace
  (:require
   [server.controllers.aws.s3 :as aws-s3]))
   
(aws-s3/delete-object-by-url! url)
;; OR
(aws-s3/delete-object-by-key! key)

Client-side usage

Upload an object like so (where uploaded is a core.async channel):

(ns client.some.namespace
  (:require 
    [s3-beam.client :as s3]))
    
(s3/s3-pipe uploaded)
    

For more info on how to use channels with s3-beam, see the s3-beam documentation: https://github.com/martinklepsch/s3-beam#3-integrate-the-upload-pipeline-into-your-frontend

Obscure name

s3-crewser is a silly name made from s3 CReate dElete for broWSER

About

AWS s3 upload and delete recipe for clojure(script) web apps

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors