This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-02-03
Channels
- # aleph (1)
- # announcements (3)
- # aws (36)
- # babashka (35)
- # beginners (25)
- # cider (14)
- # clj-kondo (3)
- # clojure (154)
- # clojure-europe (8)
- # clojure-italy (2)
- # clojure-nl (5)
- # clojure-serbia (1)
- # clojure-uk (133)
- # clojurescript (36)
- # cursive (15)
- # data-science (7)
- # datomic (16)
- # fulcro (34)
- # immutant (9)
- # jackdaw (5)
- # jobs (1)
- # leiningen (39)
- # off-topic (25)
- # pathom (42)
- # planck (13)
- # play-clj (1)
- # re-frame (18)
- # reagent (6)
- # reitit (3)
- # remote-jobs (1)
- # ring-swagger (16)
- # shadow-cljs (67)
- # sql (22)
- # testing (1)
- # uncomplicate (2)
- # vim (21)
- # vscode (6)
I am doing a :PutObject
as described here. https://github.com/cognitect-labs/aws-api/blob/master/examples/s3_examples.clj#L58
Though I would like to see the response I get back to confirm that there was no errors. I can see this in the readme but don’t understand how I use it. https://github.com/cognitect-labs/aws-api/blob/master/examples/s3_examples.clj#L58
The response is in the metadata of the return of invoke
(used here in the same example file: https://github.com/cognitect-labs/aws-api/blob/5cad085173df0ab48d64823b8a9692b73a3b4ab7/examples/s3_examples.clj#L47)
But that is only for the repl @dchelimsky
^
(meta (aws/invoke client op))
I think you’ll find an :http-response key in the meta where you can check the status code
ah! makes total sense.
Realised I shared the same links. Was meaning to reference this in the readme. (-> client aws/ops op :response)
So I thought there must be some key I can use to get the response. https://github.com/cognitect-labs/aws-api#responses-success-failure
How do I get that map?
I ended up doing this… (-> (S3-writer! file-path id (:body response)) (contains? :ETag))
because I couldn’t get a map back
Give me a sec. Was about to go home. Will boot up quick and see if I can try what you are saying.
Doing this in the repl (S3-writer! "/test/" "hello.txt" (.getBytes "Oh hai!"))
Returns an {:ETag "\".........\""}
This is how S3-writer! is defined.
(defn S3-writer!
[file-path file-name data]
(aws/invoke s3 {:op :PutObject :request {:Bucket bucket-name
:Key (str partner-folder-name file-path file-name)
:Body data}}))
(aws/doc s3client :PutObject) ->
-------------------------
Response
{:RequestCharged [:one-of ["requester"]],
:ETag string,
:SSECustomerKeyMD5 string,
:SSEKMSEncryptionContext string,
:ServerSideEncryption [:one-of ["AES256" "aws:kms"]],
:SSECustomerAlgorithm string,
:SSEKMSKeyId string,
:Expiration string,
:VersionId string}
if the map has a key :cognitect.anomalies/category
, that means something has gone wrong
When I run this from the S3 examples aws-api/examples/s3_examples.clj
(aws/invoke s3 {:op :PutObject :request {:Bucket bucket-name :Key "hello.txt"
:Body (.getBytes "Oh hai!")}})
I only get back the :ETag
in the repl.yes, that is correct https://clojurians.slack.com/archives/C09N0H1RB/p1580757828051300
As referenced above. I ended up piping it into a contains?
to check for the tag. But it seems like the wrong way to be checking…
personally I would check for the presence of error, instead of the presence of the ETag
and I can't say for certain that there's not a request that might not return an ETag at all
Ok thanks. That makes sense.
Looks more sane wrapping it with anomaly?
than what I had.