{"id":18273455,"url":"https://github.com/arraypress/s3-signer","last_synced_at":"2026-01-25T09:35:54.759Z","repository":{"id":203400839,"uuid":"709521722","full_name":"arraypress/s3-signer","owner":"arraypress","description":"A robust, lightweight library to generate presigned URLs for various S3-compatible storage providers, including Cloudflare R2, Linode, Amazon, and more.","archived":false,"fork":false,"pushed_at":"2024-11-06T20:57:08.000Z","size":51,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-02T22:59:03.196Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arraypress.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-10-24T21:10:17.000Z","updated_at":"2024-11-06T20:57:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"cab3e578-9419-4ebd-85f3-767009d4ef47","html_url":"https://github.com/arraypress/s3-signer","commit_stats":null,"previous_names":["arraypress/s3-signer"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/arraypress/s3-signer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arraypress%2Fs3-signer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arraypress%2Fs3-signer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arraypress%2Fs3-signer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arraypress%2Fs3-signer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arraypress","download_url":"https://codeload.github.com/arraypress/s3-signer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arraypress%2Fs3-signer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28750875,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-25T09:00:19.176Z","status":"ssl_error","status_checked_at":"2026-01-25T09:00:04.131Z","response_time":113,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T12:06:32.177Z","updated_at":"2026-01-25T09:35:54.743Z","avatar_url":"https://github.com/arraypress.png","language":"PHP","readme":"# S3 Signer Library for Pre-signed URLs\n\nThe S3 Signer Library streamlines generating pre-signed URLs for Amazon S3 objects, facilitating secure, temporary access without directly exposing AWS credentials. This library is essential for applications requiring secure, time-limited access to S3 objects, such as sharing private files or providing temporary download links.\n\n## Key Features\n\n- **Support for Path-Style and Virtual-Hosted Style URLs:** Offers flexibility in URL format to accommodate various bucket naming conventions and requirements.\n- **Configurable URL Validity:** Customize the duration for which the pre-signed URL remains valid, from minutes to days.\n- **Extra Query Parameters:** Append additional query parameters to the generated URLs for fine-grained control over access.\n- **Compatibility with S3 and S3-like Services:** Designed to work seamlessly not just with AWS S3, but also with S3-compatible services such as Cloudflare R2, making it versatile for different storage solutions.\n\n## Installation\n\nUse Composer to install the S3 Signer Library into your project:\n\n```bash\ncomposer require arraypress/s3-signer\n```\n\n## Quick Start\n\nAfter installation, include the Composer autoloader in your PHP script:\n\n```php\nrequire 'vendor/autoload.php';\n```\n\nCreate an instance of the `Signer` class with your S3 credentials and endpoint:\n\n```php\nuse ArrayPress\\S3\\Signer\\Signer;\n\n$accessKey = 'your-access-key-id';\n$secretKey = 'your-secret-access-key';\n$endpoint = '{account_id}.r2.cloudflarestorage.com'; // Or your S3-compatible service endpoint\n$region = 'auto';\n\n$signer = new Signer( $accessKey, $secretKey, $endpoint, $region );\n```\n\nGenerate a pre-signed URL for an S3 object:\n\n```php\n$bucket = 'your-bucket-name';\n$objectKey = 'mydownload.zip';\n$duration = 60; // URL is valid for 60 minutes\n\n$signedUrl = $signer-\u003egetObjectUrl( $bucket, $objectKey, $duration );\n\necho \"Pre-Signed URL: $signedUrl\\n\";\n```\n\n## Advanced Usage\n\nYou can customize the behavior of the Signer class further by using the available setter methods. These methods allow you to dynamically set the properties of your Signer instance to cater to specific requirements of your S3 or S3-compatible service operations.\n\n### Set Access Key ID\nSet the AWS S3 Access Key ID to authenticate your requests.\n\n```php\n$signer-\u003esetAccessKey( 'your-access-key-id' );\n```\n\nThis method validates and sets the Access Key ID used for S3 operations, ensuring it meets AWS's required format.\n\n### Set Secret Access Key\nSet the AWS S3 Secret Access Key corresponding to your Access Key ID.\n\n```php\n$signer-\u003esetSecretKey( 'your-secret-access-key' );\n```\n\nThe Secret Access Key is crucial for signing your requests securely. This method also validates the key to ensure it adheres to AWS standards.\n\n### Set Endpoint\nSpecify the endpoint URL of your S3 or S3-compatible service.\n\n```php\n$signer-\u003esetEndpoint( 's3.amazonaws.com' );\n```\n\nUse this method to set the endpoint to which the S3 requests are sent. It's validated to ensure proper URL format.\n\n### Set Region\nDefine the AWS region where your S3 bucket resides.\n\n```php\n$signer-\u003esetRegion( 'us-west-2' );\n```\n\nSetting the correct region is essential for constructing the signed URL and ensuring it routes to the right data center.\n\n### Set Path Style\nToggle between using path-style and virtual-hosted-style URLs.\n\n```php\n$signer-\u003esetPathStyle( true ); // Use path-style URLs\n```\n\nPath-style URLs are gradually being phased out in favor of virtual-hosted-style URLs by AWS, but they may still be required or preferred in certain situations or with specific S3-compatible services.\n\n### Set Extra Query String\nAppend additional query parameters to your pre-signed URL.\n\n```php\n$signer-\u003esetExtraQueryString( 'versionId=1234' );\n```\n\nThis method allows you to add extra query string parameters, providing flexibility for version control, access management, or other service-specific features.\n\n## Example Usage\nHere's how you might use these methods together to configure a Signer instance for generating a pre-signed URL:\n\n```php\n$signer = new Signer( 'access-key-id', 'secret-access-key', 's3.amazonaws.com' );\n$signer-\u003esetRegion( 'us-west-2' ); \n$signer-\u003esetPathStyle( false ); // Use virtual-hosted-style URLs\n$signer-\u003esetExtraQueryString( 'response-content-disposition=attachment' );\n\n$signedUrl = $signer-\u003egetObjectUrl( 'your-bucket-name', 'path/to/your/object', 60 );\necho \"Pre-Signed URL: $signedUrl\\n\"; \n```\n\nIn this example, we've configured the Signer to generate a virtual-hosted-style URL for an object, valid for 60 minutes, and with an extra query parameter instructing S3 to prompt the user to download the object when accessed.\n\n## Supported Providers\n\nThis library supports generating pre-signed URLs for AWS S3 and other S3-compatible storage solutions adhering to the SigV4 signing process. Supported providers include:\n\n* **AWS S3:** The original and most comprehensive cloud storage service.\n* **Cloudflare R2:** Offers compatibility with S3 APIs and competitive pricing.\n* **DigitalOcean Spaces:** Provides simple, scalable storage with S3-compatible APIs.\n* **Linode Object Storage:** Offers S3-compatible storage for storing and accessing data.\n* **And more:** Any S3-compatible service using SigV4 can work with this library.\n\n## Using the getObjectUrl Helper Function\n\nYou can also use the `getObjectUrl` helper function for a more straightforward approach to generate pre-signed URLs:\n\n```php\n$signedUrl = getObjectUrl(\n    'your-access-key-id',\n    'your-secret-access-key',\n    's3.amazonaws.com',\n    'your-bucket-name',\n    'path/to/your/object',\n    60, // Duration in minutes\n    '', // Extra query string\n    'us-west-2', // Region\n    true // Use path style\n);\n\necho \"Pre-Signed URL using helper function: $signedUrl\\n\";\n```\n\n## Contributions\n\nContributions to this library are highly appreciated. Raise issues on GitHub or submit pull requests for bug\nfixes or new features. Share feedback and suggestions for improvements.\n\n## License: GPLv2 or later\n\nThis program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public\nLicense as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later\nversion.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied\nwarranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farraypress%2Fs3-signer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farraypress%2Fs3-signer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farraypress%2Fs3-signer/lists"}