add cache-control and expires options#318
Conversation
Signed-off-by: tombokombo <hulata@sysart.tech>
|
@aykutfarsak @ilkinulas guys could you please review, thanks. |
@tombokombo there has been a lot of development in s5cmd these days, this PR is waiting in the queue, I will take a look at it soon. |
Signed-off-by: tombokombo <hulata@sysart.tech>
|
With invalid expires date value, aws cli returns an error: So I am not sure if we should ignore the invalid expire date error. Maybe we can increase the log level to What do you think @ilkinulas? |
Good catch @aykutfarsak 👍 Let's add a validation for |
There was a problem hiding this comment.
With invalid expires date value, aws cli returns an error:
➜ aws s3 cp file s3://bucket/prefix --expires "2024-13-01T20:30:00Z" upload failed: ./Makefile to s3://bucket/prefix/file Parameter validation failed: Invalid type for parameter Expires, value: 2024-13-01T20:30:00Z, type: <class 'str'>, valid types: <class 'datetime.datetime'>, timestamp-string ➜ echo $? 1So I am not sure if we should ignore the invalid expire date error. Maybe we can increase the log level to
erroror return the error immediately.
What do you think @ilkinulas?Good catch @aykutfarsak Let's add a validation for
--expiresparameter
Actually, date string validation is already in place, I just choose to print debug message in case of invalid date, so maybe log.Error instead of log.Debug would by enough?
storage/s3.go
Outdated
| if err == nil { | ||
| input.Expires = aws.Time(t) | ||
| } else { | ||
| msg := log.DebugMessage{Err: err.Error()} |
There was a problem hiding this comment.
I was trying invalid time formats to see s3 behavior, here are my findings:
- if we upload a new object s3 ignores invalid
Expiresmetadata. - if we override an existing s3 objects (which has a valid
Expiresmetadata) with an invalid expires value, s3 deletes the current object's Expires metadata.
So, it would be better to return the error and do not cp/mv any objects in case of unparsable --expires values.
Signed-off-by: tombokombo <tombo@sysart.tech>
Co-authored-by: Aykut Farsak <aykutfarsak@gmail.com>
Co-authored-by: Aykut Farsak <aykutfarsak@gmail.com>
|
@tombokombo thank you for the contribution. |
Hello, this PR add support for setting cache-control and expires header to s3 object, same as aws cli