The URL has a time period during which it expires.
Signature Version 2
htt ps: //bucket.s3.amazonaws.com/foo.txt? AWSAccessKeyId = AKIAABCDEFGHIJK & Expires = 1508608760 & Signature = xxxxxxxxxxx
Expires gives time in UTC.
$ date -d @1508608760 Sat Oct 21 17:59:20 UTC 2017
You can extract the value and compare it with the current time in UTC [ time() ], and then decide whether or not to recover.
Signature Version 4HTT ps: //s3.amazonaws.com/bucket/foo.txt X-Amz-Algorithm = AWS4-HMAC-SHA256 & X-Amz-Expires = 3600 & X-Amz-credentials = AKIAJRZXXXXXXXXXus-east-1% 2Fs3% 2Faws4_request & X-Amz-SignedHeaders = host & X-Amz-Date = 20171021T190750Z & X- Amz-Signature = 8b84ae9b59e9f8a8d7066ecc39e797c8dc29848abcdef61717
X-Amz-Date gives UTC time in ISO 8601 format.
You can extract the value, convert it to the / UTC era and compare it with the current time in UTC [time ()], and then regenerate it or not.
source share