aws

http://status.aws.amazon.com/ https://www.expeditedssl.com/aws-in-plain-english
kirill.salykin 2020-01-13T10:02:59.003200Z

hi, I am trying to upload big file (150mb) to the s3 using input-stream, but seems that it is being consumed into byte-array with cognitect.aws.util/input-stream->byte-array

kirill.salykin 2020-01-13T10:03:07.003500Z

is there a way to use stream?

kirill.salykin 2020-01-13T10:03:46.004Z

(with-open [stream (io/input-stream tempfile)]
                let [response (aws/invoke s3 {:op      :PutObject
                                               :request {:Bucket        (:bucket (config/aws))
                                                         :Key           bucket-key
                                                         :ContentType   content-type
                                                         :ContentLength size
                                                         :ACL           "public-read"
                                                         :Body          stream}})])

kirill.salykin 2020-01-13T10:05:34.004400Z

Should I provide ByteBuffer to the s3 client?

kirill.salykin 2020-01-13T11:57:08.005400Z

I’ve tried with MappedByteBuffer - doesnt work

(with-open [stream (<http://java.io|java.io>.FileInputStream. tempfile)]
                (let [channel  (.getChannel stream)
                      buffer   (.map channel java.nio.channels.FileChannel$MapMode/READ_ONLY 0 (.size channel))
                      response (aws/invoke s3 {:op      :PutObject
                                               :request {:Bucket        (:bucket (config/aws))
                                                         :Key           bucket-key
                                                         :ContentType   content-type
                                                         :ContentLength size
                                                         :ACL           "public-read"
                                                         :Body          buffer}})]))

kulminaator 2020-01-13T17:59:24.005800Z

aws s3 expects big uploads to be happening in chunks

kulminaator 2020-01-13T17:59:49.006400Z

not as one long long stream (if you put yourself in their shoes you wouldn't want to wait for long and possibly slow uploads either)

kulminaator 2020-01-13T18:00:08.006800Z

see multipart upload docs , i think you should rather refer to that ...