Skip to content

Commit

Permalink
fix: update resource with id (#3405)
Browse files Browse the repository at this point in the history
* chore: update presign expires

* fix: update resource with id

---------

Co-authored-by: timothy <timothy123890511@gmail.com>
  • Loading branch information
hchengting and timothy committed May 19, 2024
1 parent 8f6d387 commit 52ebfd7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions server/service/s3_object_presigner/s3_object_presigner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand All @@ -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_{
Expand Down

0 comments on commit 52ebfd7

Please sign in to comment.