An open API service indexing awesome lists of open source software.

https://github.com/benhowell/s3-crewser

AWS s3 upload and delete recipe for clojure(script) web apps
https://github.com/benhowell/s3-crewser

amazonica aws clojure clojurescript s3 s3-beam

Last synced: about 1 month ago
JSON representation

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

Awesome Lists containing this project

README

          

# 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](https://github.com/mcohen01/amazonica) library has much more functionality than what's demonstrated here.

Requires:
- https://github.com/martinklepsch/s3-beam
- https://github.com/mcohen01/amazonica

## Server-side config
Wherever you define your routes, add a path for "/sign" like so:

```clj
(defroutes

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

)
```

## Server-side usage
List objects like so:
```clj
(ns server.some.namespace
(:require
[server.controllers.aws.s3 :as aws-s3]))

(aws-s3/list-objects)
```

Delete an object like so:
```clj
(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):
```cljs
(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