Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add S3Key implementation to construct S3 paths #21

Merged
merged 8 commits into from
Oct 15, 2024
Merged

Conversation

thekid
Copy link
Member

@thekid thekid commented Oct 15, 2024

Example:

use com\amazon\aws\S3Key;

-  $transfer= $s3->open('PUT', 'target/'.$file->filename, headers);
+  $transfer= $s3->open('PUT', new S3Key('target', $file->filename), $headers);

This supports arbitray filenames, including ones with characters that need to be encoded. The reason this class is called S3Key is that S3 does not double-encode the path component in the canonical request.

@thekid thekid added the enhancement New feature or request label Oct 15, 2024
/** Signs a given target (optionally including parameters) with a given expiry time */
public function sign(string $target, int $expires= 3600, $time= null): string {
public function sign($target, int $expires= 3600, $time= null): string {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With PHP 8.0+, we could use string|S3Key here, see https://wiki.php.net/rfc/union_types_v2

@thekid thekid merged commit f125a6b into main Oct 15, 2024
20 checks passed
@thekid thekid deleted the feature/s3-key branch October 15, 2024 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant