rust-s3
rust-s3 copied to clipboard
add custom headers on put_object requests
This is a repost of #155 (rebased on top of master), because I don't know why you closed the previous PR, and thus if this feature is wanted or not ?
I'm quite lazy, so I didn't want to upload objects with a presigned put (which allows for passing custom metadata). This means I had to be able to pass custom headers (in theory I only needed to add "x-amz-meta-*", but while we are at it, wa can as well let the user add any possible header, right ?). This is an attempt at solving this problem. However, I do think that this PR is less than ideal because
- a builder pattern would probably prevent adding too many similar functions, and be better than this hacky patch
- we forward custom_headers to the s3 endpoint both for submitting parts & for initiating the upload, without distinguishing both (in the event of a multi-parts upload of course, otherwise there is no such dichotomy because there is only a single request). However adding two arguments would be tedious and there is no way to distinguish the headers targeting the parts from those targeting the InitiateMultipartUpload query. So I decided to send the same headers for both.
Anyway, do you think something like that would be valuable ?
@nightmared once more thanks for being patient, I think I've tried merging this in but ran into some sync/async trouble, once the 0.27.0 is out, I'll give it one more go, I do think it would be useful/valuable to have it in
I have rebased this against master.
Please note that there should be at least one expected failure with clippy:
cargo clippy --all-features -- -D warnings
Checking aws-creds v0.26.2 (/home/nightmared/dev/rust-s3/aws-creds)
error: in an `if` condition, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a `let`
--> aws-creds/src/credentials.rs:284:47
|
284 | .map_or(false, |uuid| {
| _______________________________________________^
285 | | uuid.len() >= 10 && &uuid[..10] == "Amazon EC2"
286 | | }))
| |_________________________^
|
= note: `-D clippy::blocks-in-if-conditions` implied by `-D warnings`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#blocks_in_if_conditions
error: could not compile `aws-creds` due to previous error
However I did not fix it here because I already did so in https://github.com/durch/rust-s3/pull/189.
@nightmared closing for now, not sure how badly you need something like this, I'd be happy to take a stab at it eventually
No problem, I can work around it by making a presigned put.