{"id":22292620,"url":"https://github.com/ericnorris/amazon-s3-php","last_synced_at":"2025-07-28T23:33:33.663Z","repository":{"id":21914474,"uuid":"25238612","full_name":"ericnorris/amazon-s3-php","owner":"ericnorris","description":"Simple, lightweight, and fast S3 library for PHP.","archived":false,"fork":false,"pushed_at":"2023-04-10T15:36:21.000Z","size":328,"stargazers_count":20,"open_issues_count":1,"forks_count":11,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-06T09:42:54.313Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ericnorris.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2014-10-15T04:17:25.000Z","updated_at":"2024-06-19T10:50:13.000Z","dependencies_parsed_at":"2024-06-21T05:46:15.205Z","dependency_job_id":"f14d730b-4ad7-4ca4-8e1c-08b402eb47cd","html_url":"https://github.com/ericnorris/amazon-s3-php","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericnorris%2Famazon-s3-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericnorris%2Famazon-s3-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericnorris%2Famazon-s3-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericnorris%2Famazon-s3-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ericnorris","download_url":"https://codeload.github.com/ericnorris/amazon-s3-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227963336,"owners_count":17848092,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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-12-03T17:23:11.209Z","updated_at":"2024-12-03T17:23:11.895Z","avatar_url":"https://github.com/ericnorris.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"amazon-s3-php\n=============\n\nInspired by [tpyo/amazon-s3-php-class](https://github.com/tpyo/amazon-s3-php-class), this is a simple and configurable S3 PHP library. It was written to be as lightweight as possible, while still enabling access to all of the features of AWS (e.g. server-side encryption).\n\nAdditionally, `curl_multi_exec` is used (rather than `curl_exec`) for better performance when doing bulk operations.\n\n## Usage\n`$client = new S3($access_key, $secret_key [, $endpoint = null]);`\n\n## Configuration\n### Specify Custom Curl Options\n* `$client-\u003euseCurlOpts($curl_opts_array)`\n\nProvides the S3 class with any curl options to use in making requests.\n\nThe following options are passed by default in order to prevent 'hung' requests:\n```php\ncurl_opts = array(\n    CURLOPT_CONNECTTIMEOUT =\u003e 30,\n    CURLOPT_LOW_SPEED_LIMIT =\u003e 1,\n    CURLOPT_LOW_SPEED_TIME =\u003e 30\n);\n```\n**Note:** *If you call this method, these defaults will not be used.*\n\n### Send Additional AWS Headers\nAll of the available S3 operations take an optional `$headers` array that will be passed along to S3. These can include `x-amz-meta-`, `x-amz-server-side-encryption`, `Content-Type`, etc. Any Amazon headers specified will be properly included in the AWS signature as per [AWS Signature v2](http://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html).\n\nRequest headers that are common to all requests are located [here](http://docs.aws.amazon.com/AmazonS3/latest/API/RESTCommonRequestHeaders.html).\n\n## S3Response Class\nAll methods in the S3 class will return an instance of the S3Response class.\n```php\nclass S3Response {\n    public $error;    // null if no error\n    public $code;     // response code from AWS\n    public $headers;  // response headers from AWS\n    public $body;     // response body from AWS\n}\n```\n\nIf there is an error in curl or an error is returned from AWS, `$response-\u003eerror` will be non-null and set to the following array:\n\n```\n$error = array(\n    'code' =\u003e xxx, // error code from either curl or AWS\n    'message' =\u003e xxx, // error string from either curl or AWS\n    'resource' =\u003e [optional] // the S3 resource frmo the request\n)\n```\n\n## Methods\n`putObject($bucket, $path, $file [, $headers = array()])`\n* Uploads a file to the specified path and bucket. `$file` can either be the raw representation of a file (e.g. the result of `file_get_contents()`) or a valid stream resource.\n* [AWS Documentation](http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPUT.html)\n\n`getObjectInfo($bucket, $path, [, $headers = array()])`\n* Retrieves metadata for the object.\n* [AWS Documentation](http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectHEAD.html)\n\n`getObject($bucket, $path [, $resource = null  [, $headers = array()]])`\n* Retrieves the contents of an object. If `$resource` is a valid stream resource, the contents will be written to the stream. Otherwise `$response-\u003ebody` will contain the contents of the file.\n* [AWS Documentation](http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectGET.html)\n\n`deleteObject($bucket, $path [, $headers = array()])`\n* Deletes an object from S3.\n* [AWS Documentation](http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectDELETE.html)\n\n`getBucket($bucket [, $headers = array()])`\n* Returns a parsed response from S3 listing the contents of the specified bucket.\n* [AWS Documentation](http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketGET.html)\n\n## Examples\nInstantiating the S3 class:\n```php\n$client = new S3(ACCESS_KEY, SECRET_KEY);\n\n// [OPTIONAL] Specify different curl options\n$client-\u003euseCurlOpts(array(\n    CURLOPT_MAX_RECV_SPEED_LARGE =\u003e 1048576,\n    CURLOPT_CONNECTTIMEOUT =\u003e 10\n));\n```\n\n### Upload an object\n```\n$response = $client-\u003eputObject(\n    'bucket',\n    'hello_world.txt',\n    'hello world!',\n    array(\n        'Content-Type' =\u003e 'text/plain'\n    )\n);\n\nprint_r($response);\n```\n\nOutput:\n```\nS3Response Object\n(\n    [error] =\u003e null\n    [code] =\u003e 200\n    [headers] =\u003e Array\n        (\n            [x-amz-id-2] =\u003e ...\n            [x-amz-request-id] =\u003e ...\n            [ETag] =\u003e \"...\"\n            [Content-Length] =\u003e ...\n            [Server] =\u003e ...\n        )\n    [body] =\u003e null\n)\n```\n### Download an object\n```php\n$resource = tmpfile();\n$client-\u003egetObject('bucket', 'hello_world.txt', $resource);\n\nprint_r($response);\necho stream_get_contents($resource) . \"\\n\";\n```\nOutput:\n```\nS3Response Object\n(\n    [error] =\u003e\n    [code] =\u003e 200\n    [headers] =\u003e Array\n        (\n            [x-amz-id-2] =\u003e ...\n            [x-amz-request-id] =\u003e ...\n            [ETag] =\u003e \"...\"\n            [Accept-Ranges] =\u003e bytes\n            [Content-Type] =\u003e text/plain\n            [Content-Length] =\u003e 12\n            [Server] =\u003e ...\n        )\n\n    [body] =\u003e Resource id #17\n)\n\nhello world!\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericnorris%2Famazon-s3-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fericnorris%2Famazon-s3-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericnorris%2Famazon-s3-php/lists"}