fix: update resource with id (#3405)

* chore: update presign expires

* fix: update resource with id

---------

Co-authored-by: timothy <timothy123890511@gmail.com>
This commit is contained in:
Timothy 2024-05-19 23:18:03 +08:00 committed by GitHub
parent 8f6d38719f
commit 52ebfd703c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -45,9 +45,9 @@ func (p *S3ObjectPresigner) CheckAndPresign(ctx context.Context) {
}
if s3ObjectPayload.LastPresignedTime != nil {
// Skip if the presigned URL is still valid for the next 6 days.
// The default expiration time is 7 days.
if time.Now().Before(s3ObjectPayload.LastPresignedTime.AsTime().Add(6 * 24 * time.Hour)) {
// Skip if the presigned URL is still valid for the next 4 days.
// The expiration time is set to 5 days.
if time.Now().Before(s3ObjectPayload.LastPresignedTime.AsTime().Add(4 * 24 * time.Hour)) {
continue
}
}
@ -74,6 +74,7 @@ func (p *S3ObjectPresigner) CheckAndPresign(ctx context.Context) {
s3ObjectPayload.S3Config = s3Config
s3ObjectPayload.LastPresignedTime = timestamppb.New(time.Now())
if err := p.Store.UpdateResource(ctx, &store.UpdateResource{
ID: resource.ID,
Reference: &presignURL,
Payload: &storepb.ResourcePayload{
Payload: &storepb.ResourcePayload_S3Object_{