Vebjorn Ljosa
Vebjorn Ljosa

Reputation: 18008

How do I set a timeout when getting an object from S3 with Amazonica?

I use Amazonica to download an object from S3:

(require '[amazonica.aws.s3 :as s3])

(s3/get-object "my-bucket" "foo")

However, sometimes the download hangs. How can I set a timeout?

Upvotes: 3

Views: 1226

Answers (1)

Vebjorn Ljosa
Vebjorn Ljosa

Reputation: 18008

s3/get-object can also take keyword arguments:

(require '[amazonica.aws.s3 :as s3])

(s3/get-object :bucket-name "my-bucket" :key "foo")

You can add additional keyword arguments for any accessors on GetObjectRequest. In this case, you want the method SdkClientExecutionTimeout to be called, so do this:

(s3/get-object :bucket-name "my-bucket" :key "foo"
               :sdk-client-execution-timeout 10000)

Upvotes: 6

Related Questions