Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with server-side encryption using customer-provided keys for S3 Transfer Manager #405

Open
irinarenteria opened this issue Mar 4, 2019 · 5 comments

Comments

@irinarenteria
Copy link
Contributor

Hi,

Sorry in advance if this has already been covered. This is an issue similar to #196. I'm trying to upload a file using the S3 transfer manager and I'm looking for a way to add the SSE customer key to the request, but I haven't been successful yet.

This request works but the file is not encrypted:

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

(s3-transfer/upload "bucket-name" "key-name" "file-path")

I've tried this:

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

(s3-transfer/upload "bucket-name" "key-name" "file-path" {:sse-algorithm "AES256" :sse-key (encryption-key)}

But I get this error:

IllegalArgumentException No coercion is available to turn test.json into an object of type class java.io.InputStream  amazonica.core/coerce-value (core.clj:393)

I dug a bit through AWS Java SDK docs and it seems like an Object Metadata map can only be provided for input stream, which is probably why it's trying to process the file as an input stream.

The recommended solution in #196 hasn't worked for me because it doesn't seem like keyword arguments are supported for the upload request:

(s3-transfer/upload :bucket-name "bucket-name" :key "key-name" :file "file-path")

IllegalArgumentException wrong number of arguments  sun.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)

Am I missing something obvious or is there another way to provide the key?

Thank you in advance!

@mcohen01
Copy link
Owner

mcohen01 commented Mar 4, 2019

i think (s3-transfer/upload :bucket-name "foo" :key "bar" :file java.util.File :sse-customer-key (encryption-key)) should work. You want the Java SDK upload() that takes a PutObjectRequest arg, rather than the one that takes bucket, key, and file args.

@irinarenteria
Copy link
Contributor Author

Thank you for the quick reply, @mcohen01! I tried that call but got the same error:

IllegalArgumentException wrong number of arguments  sun.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)

Does Amazonica reflect that upload() function automatically when the correct args are passed in or is there something else I'm supposed to import/do?

@mcohen01
Copy link
Owner

mcohen01 commented Mar 5, 2019

Apologies, but I think you've run into a persistent bug. The code that picks the java method to invoke has pretty much always been flaky with overloaded methods. This is a shitty answer but unfortunately I just don't have any spare cycles to dig into this at the moment....

@irinarenteria
Copy link
Contributor Author

No worries at all, @mcohen01! I appreciate you digging into it. I'm going to go with a different approach for now anyway. Should I leave this issue open meanwhile? I wish I could help, but I don't have much time for open-source work at the moment either. Thank you for following up quickly!

@mcohen01
Copy link
Owner

mcohen01 commented Mar 6, 2019

yeah i would leave it open

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants