This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-04-03
Channels
- # announcements (4)
- # aws (13)
- # babashka (35)
- # beginners (162)
- # boot (8)
- # calva (5)
- # chlorine-clover (15)
- # cider (64)
- # clj-kondo (20)
- # cljs-dev (29)
- # clojars (6)
- # clojure (166)
- # clojure-europe (3)
- # clojure-finland (6)
- # clojure-france (8)
- # clojure-germany (3)
- # clojure-italy (3)
- # clojure-nl (7)
- # clojure-spec (49)
- # clojure-uk (83)
- # clojurescript (39)
- # clojurex (5)
- # core-typed (2)
- # cursive (3)
- # data-science (17)
- # datascript (3)
- # datomic (22)
- # exercism (5)
- # fulcro (3)
- # jobs-discuss (2)
- # joker (2)
- # kaocha (3)
- # malli (26)
- # off-topic (89)
- # pathom (10)
- # pedestal (14)
- # protorepl (14)
- # re-frame (23)
- # reitit (2)
- # shadow-cljs (27)
- # slack-help (10)
- # spacemacs (14)
- # tools-deps (10)
- # tree-sitter (3)
- # xtdb (19)
- # yada (2)
does anyone have an example of downloading a binary file from S3? I’ve attempted to use cognitect, amazonica, and clj-aws-s3, and all download a file, but with different MD5s than aws-cli
what I’m doing seems pretty simple:
(let [resp (aws/invoke s3-client {:op :GetObject :request {:Bucket bucket :Key filename}})]
(io/copy (:Body resp) (io/output-stream (io/file filename)))
resp)
hrm, the pure java version works:
(let [java-client (com.amazonaws.services.s3.AmazonS3ClientBuilder/defaultClient)]
(with-open [obj (.getObject java-client (com.amazonaws.services.s3.model.GetObjectRequest. bucket key))]
(java.nio.file.Files/copy (.getObjectContent obj) (.toPath (io/file dest-path)) (into-array java.nio.file.CopyOption [java.nio.file.StandardCopyOption/REPLACE_EXISTING]))))
$ md5 datomic-pro-*.zip
MD5 (datomic-pro-0.9.6045-amazonica.zip) = 9b1c544ce7b68a6d4bcc7477c501cf6a
MD5 (datomic-pro-0.9.6045-aws-cli.zip) = 50d60403c5cf505ac12f31a7081995b5
MD5 (datomic-pro-0.9.6045-clj-s3.zip) = 9b1c544ce7b68a6d4bcc7477c501cf6a
MD5 (datomic-pro-0.9.6045-cognitect.zip) = 3d95d706e81ea53363b2c3f29b64ec74
MD5 (datomic-pro-0.9.6045-java.zip) = 50d60403c5cf505ac12f31a7081995b5
-rw-r--r-- 1 arohner staff 333382279 Apr 3 10:57 datomic-pro-0.9.6045-amazonica.zip
-rw-r--r-- 1 arohner staff 333390244 Apr 3 10:12 datomic-pro-0.9.6045-aws-cli.zip
-rw-r--r-- 1 arohner staff 333382279 Apr 3 11:12 datomic-pro-0.9.6045-clj-s3.zip
-rw-r--r-- 1 arohner staff 333389824 Apr 3 11:29 datomic-pro-0.9.6045-cognitect.zip
-rw-r--r-- 1 arohner staff 333390244 Apr 3 12:33 datomic-pro-0.9.6045-java.zip
([input output & opts])
Copies input to output. Returns nil or throws IOException.
Input may be an InputStream, Reader, File, byte[], char[], or String.
Output may be an OutputStream, Writer, or File.
Options are key/value pairs and may be one of
:buffer-size buffer size to use, default is 1024.
:encoding encoding to use if converting between
byte and char streams.
Does not close any streams except those it opens itself
(on a File).