{"id":4711,"url":"https://github.com/benjreinhart/react-native-aws3","last_synced_at":"2025-05-16T13:06:05.541Z","repository":{"id":46494272,"uuid":"54697803","full_name":"benjreinhart/react-native-aws3","owner":"benjreinhart","description":"Pure JavaScript React Native library for uploading to AWS S3","archived":false,"fork":false,"pushed_at":"2021-04-22T06:22:51.000Z","size":74,"stargazers_count":399,"open_issues_count":61,"forks_count":150,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-05-11T06:41:23.096Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/benjreinhart.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-25T05:54:24.000Z","updated_at":"2025-04-14T19:27:31.000Z","dependencies_parsed_at":"2022-09-26T18:01:16.566Z","dependency_job_id":null,"html_url":"https://github.com/benjreinhart/react-native-aws3","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benjreinhart%2Freact-native-aws3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benjreinhart%2Freact-native-aws3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benjreinhart%2Freact-native-aws3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benjreinhart%2Freact-native-aws3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benjreinhart","download_url":"https://codeload.github.com/benjreinhart/react-native-aws3/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254535827,"owners_count":22087399,"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-01-05T20:17:21.006Z","updated_at":"2025-05-16T13:06:05.517Z","avatar_url":"https://github.com/benjreinhart.png","language":"JavaScript","funding_links":[],"categories":["Components"],"sub_categories":["Backend"],"readme":"# React Native AWS3\n\nReact Native AWS3 is a module for uploading files to S3. Unlike other libraries out there, there are no native dependencies.\n\n```\nnpm install --save react-native-aws3\n```\n\n[![build status](https://circleci.com/gh/benjreinhart/react-native-aws3.svg?style=shield\u0026circle-token=c7cb5ba4654c9d66bbfeac9809e50aa0fbf0af09)](https://circleci.com/gh/benjreinhart/react-native-aws3)\n[![npm version](https://img.shields.io/npm/v/react-native-aws3.svg?style=flat-square)](https://www.npmjs.com/package/react-native-aws3)\n[![npm downloads](https://img.shields.io/npm/dm/react-native-aws3.svg?style=flat-square)](https://www.npmjs.com/package/react-native-aws3)\n\n## Note on S3 user permissions\n\nThe user associated with the `accessKey` and `secretKey` you use must have the appropriate permissions assigned to them. My user's IAM policy looks like:\n\n```json\n{\n    \"Version\": \"2012-10-17\",\n    \"Statement\": [\n        {\n            \"Sid\": \"Stmt1458840156000\",\n            \"Effect\": \"Allow\",\n            \"Action\": [\n                \"s3:GetObject\",\n                \"s3:GetObjectAcl\",\n                \"s3:GetObjectVersion\",\n                \"s3:PutObject\",\n                \"s3:PutObjectAcl\",\n                \"s3:PutObjectVersionAcl\"\n            ],\n            \"Resource\": [\n                \"arn:aws:s3:::my-bucket/uploads/*\"\n            ]\n        }\n    ]\n}\n```\n\n## Example\n\n```javascript\nimport { RNS3 } from 'react-native-aws3';\n\nconst file = {\n  // `uri` can also be a file system path (i.e. file://)\n  uri: \"assets-library://asset/asset.PNG?id=655DBE66-8008-459C-9358-914E1FB532DD\u0026ext=PNG\",\n  name: \"image.png\",\n  type: \"image/png\"\n}\n\nconst options = {\n  keyPrefix: \"uploads/\",\n  bucket: \"your-bucket\",\n  region: \"us-east-1\",\n  accessKey: \"your-access-key\",\n  secretKey: \"your-secret-key\",\n  successActionStatus: 201\n}\n\nRNS3.put(file, options).then(response =\u003e {\n  if (response.status !== 201)\n    throw new Error(\"Failed to upload image to S3\");\n  console.log(response.body);\n  /**\n   * {\n   *   postResponse: {\n   *     bucket: \"your-bucket\",\n   *     etag : \"9f620878e06d28774406017480a59fd4\",\n   *     key: \"uploads/image.png\",\n   *     location: \"https://your-bucket.s3.amazonaws.com/uploads%2Fimage.png\"\n   *   }\n   * }\n   */\n});\n```\n\n## Usage\n\n### put(file, options)\n\nUpload a file to S3.\n\nArguments:\n\n1. `file`\n  * `uri` **required** - File system URI, can be assets library path or `file://` path\n  * `name` **required** - The name of the file, will be stored as such in S3\n  * `type` **required** - The mime type, also used for `Content-Type` parameter in the S3 post policy\n2. `options`\n  * `acl` - The [Access Control List](http://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html) of this object. Defaults to `public-read`\n  * `keyPrefix` - Prefix, or path to the file on S3, i.e. `uploads/` (note the trailing slash)\n  * `bucket` **required** - Your S3 bucket\n  * `region` **required** - The region of your S3 bucket\n  * `accessKey` **required** - Your S3 `AWSAccessKeyId`\n  * `secretKey` **required** - Your S3 `AWSSecretKey`\n  * `successActionStatus` - HTTP response status if successful, defaults to 201\n  * `awsUrl` - [AWS S3 url](http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region). Defaults to `s3.amazonaws.com`\n  * `timeDelta` - Devices time offset from world clock in milliseconds, defaults to 0\n\nReturns an object that wraps an `XMLHttpRequest` instance and behaves like a promise, with the following additional methods:\n\n* `progress` - accepts a callback which will be called with an event representing the progress of the upload. Event object is of shape\n  * `loaded` - amount uploaded\n  * `total` - total amount to upload\n  * `percent` - number between 0 and 1 representing the percent completed\n* `abort` - aborts the xhr instance\n\nExamples:\n```javascript\nRNS3.put(file, options)\n  .progress((e) =\u003e console.log(e.loaded / e.total)); // or console.log(e.percent)\n\nRNS3.put(file, option)\n  .abort();\n```\n\n## TODO\n\n- [ ] Support `DeleteObject` and (authenticated) `GetObject` operations.\n\n\n## License\n\n[MIT](https://github.com/benjreinhart/react-native-aws3/blob/master/LICENSE.txt)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenjreinhart%2Freact-native-aws3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenjreinhart%2Freact-native-aws3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenjreinhart%2Freact-native-aws3/lists"}