I created a simple PHP file browser that links to files via URLs ending in the expiring generation. Therefore, for each access to the directory, a link is created for each file, which is valid for 900 seconds.
I now have a problem that the generated signatures seem to fail sometimes. Which is strange, since I intentionally used S3 external libraries to generate URLs and signatures.
In fact, I tried the following libraries for generating signatures:
Libraries internally use hash_hmac ('sha256', ... or hash_hmac ('sha1', ... - I also don't understand why differnet hashing algorithms are used.
Since the problem is the same with all libraries, it can also be in the code of the URL generation code, which is simple:
$bucket = "myBucket"; $filename = $object->Key; $linksValidForSeconds = 900; $url = $s3->get_object_url($bucket, $filename, $linksValidForSeconds);
Sp $ bucket and $ linksValidForSeconds are constant, $ filename, for example. "Media / Pictures / My Picture.png". But an event for the same variables sometimes works, soemtimes does not.
Any ideas?
Edit: Tipo / Invalid constant variable name fixed (thanks)
php amazon-s3 digital-signature
Tarnschaf
source share