1

I am trying to use the AWS SDK to access my S3 bucket and can't figure out what I'm doing wrong.

My Leiningen project file includes a dependency on the necessary CLJSJS package:

[cljsjs/aws-sdk-js "2.94.0-0"]

I then require the package in my namespace:

(ns my-ns.s3
  (:require [cljsjs.aws-sdk-js]))

I set the credentials:

(js/AWS.config.update #js{:credentials {:accessKeyId "..."
                                        :secretAccessKey "..."}})

I then run this in the REPL using CIDER (I am actually evaluating all of this in CIDER using either C-M-x or C-c C-e; haven't wired it into any yet):

(let [client (new js/AWS.S3)]
  (.listObjects client
                #js{"Bucket" "my-bucket"}
                (fn [err resp]
                  (if err
                    (js/console.error "so sad"
                                      (js/JSON.stringify err))
                    (js/console.log "so happy" resp)))))

=> #object[Request [object Object]]

All I get back is that #object reference (and I don't know what to do with that). Nothing is logged to the console and no network request goes out.

Any pointers on what I am doing wrong here, or docs I may need to review?

Details I've omitted for brevity:

  • I am pretty early in learning CLJS, have been learning JS for six months at work, and done CLJ at work for the past few years and Java a few years beyond that
  • The above code is inside a re-frame project, although I've done very little with the rest of the project
  • I previously was able to at least get CORS errors for .listBuckets, but now that call is also doing absolutely nothing -- I don't recall changing anything meaningful
MonkeyWithDarts
  • 755
  • 1
  • 7
  • 17

0 Answers0