{"id":15612399,"url":"https://github.com/jpalumickas/react-native-activestorage","last_synced_at":"2025-04-28T16:15:55.154Z","repository":{"id":42203645,"uuid":"193791434","full_name":"jpalumickas/react-native-activestorage","owner":"jpalumickas","description":"React Native support for Rails ActiveStorage","archived":false,"fork":false,"pushed_at":"2023-10-07T20:52:37.000Z","size":438,"stargazers_count":15,"open_issues_count":6,"forks_count":12,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-18T18:33:10.905Z","etag":null,"topics":["activestorage","rails","react","react-native"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/jpalumickas.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":"2019-06-25T22:26:32.000Z","updated_at":"2024-09-14T19:08:34.000Z","dependencies_parsed_at":"2024-10-22T18:04:20.278Z","dependency_job_id":null,"html_url":"https://github.com/jpalumickas/react-native-activestorage","commit_stats":{"total_commits":27,"total_committers":2,"mean_commits":13.5,"dds":0.03703703703703709,"last_synced_commit":"d65c7582b38873a9d2f3142cb1e8da848024bf0e"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpalumickas%2Freact-native-activestorage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpalumickas%2Freact-native-activestorage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpalumickas%2Freact-native-activestorage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpalumickas%2Freact-native-activestorage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jpalumickas","download_url":"https://codeload.github.com/jpalumickas/react-native-activestorage/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251342726,"owners_count":21574245,"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":["activestorage","rails","react","react-native"],"created_at":"2024-10-03T06:42:31.358Z","updated_at":"2025-04-28T16:15:55.136Z","avatar_url":"https://github.com/jpalumickas.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React Native ActiveStorage\n\nUse direct upload for uploading files to Rails ActiveStorage.\n\n## Installation\n\nInstall this package and [react-native-blob-util](react-native-blob-util)\n\n```sh\nyarn add react-native-activestorage react-native-blob-util\n```\n\n## Usage\n\n### Add Active Storage provider\n\n```jsx\nimport { ActiveStorageProvider } from 'react-native-activestorage'\n\nconst App = () =\u003e (\n  \u003cActiveStorageProvider host=\"https://localhost:4000\"\u003e\n    \u003cNavigation /\u003e\n  \u003c/ActiveStorageProvider\u003e\n)\n```\n\nYou can provide `mountPath` to provider if you have different than `/rails/active_storage`\n\n### Use with React Hooks\n\n```jsx\nimport { useDirectUpload } from 'react-native-activestorage'\n\nconst Upload = () =\u003e {\n  const onSuccess = ({ signedIds }) =\u003e {\n    // Do something;\n  }\n\n  const { upload, uploading, uploads } = useDirectUpload({ onSuccess });\n\n  const onUploadButtonClick = async () =\u003e {\n    const files = await showPicker();\n    const { signedIds } = await upload(files);\n    // Assign signed IDs\n  }\n\n  return (\n    \u003cView\u003e\n      \u003cView onClick={onUploadButtonClick}\u003e\n        \u003cText\u003eUpload\u003c/Text\u003e\n      \u003c/View\u003e\n\n      {uploads.map(upload =\u003e (\n        \u003cUploadItem upload={upload} key={upload.id} /\u003e\n      ))}\n    \u003c/View\u003e\n  )\n}\n```\n\n### Use with React Component\n\n```jsx\nimport { DirectUpload } from 'react-native-activestorage'\n\nconst Upload = () =\u003e (\n  \u003cDirectUpload onSuccess={({ signedIds }) =\u003e console.warn({ signedIds })}\u003e\n    {({ upload, uploading, uploads }) =\u003e (\n      \u003cView\u003e\n        \u003cView onClick={() =\u003e showPicker((files) =\u003e upload(files))}\u003e\n          \u003cText\u003eUpload\u003c/Text\u003e\n        \u003c/View\u003e\n        {uploads.map(upload =\u003e \u003cUploadItem upload={upload} key={upload.id} /\u003e)}\n      \u003c/View\u003e\n    )}\n  \u003c/DirectUpload\u003e\n)\n```\n\n### Use `directUpload` without React\n\n```js\nimport { directUpload } from 'react-native-activestorage'\n\nconst file = {\n  name: 'image.jpg',\n  size: 123456,\n  type: 'image/jpeg',\n  path: '/var/lib/...'\n}\n\nconst directUploadsUrl = 'https://localhost:3000/rails/active_storage/direct_uploads';\n\nconst onStatusChange = ({ status, progress, cancel }) =\u003e {\n  // status - waiting/uploading/success/error/canceled\n  // progress - 0-100% (for uploading status)\n  // cancel - function to stop uploading a file\n}\n\ndirectUpload({ file, directUploadsUrl, onStatusChange });\n```\n\n## License\n\nThe package is available as open source under the terms of the [MIT License][license].\n\n[license]: https://raw.githubusercontent.com/jpalumickas/react-native-activestorage/master/LICENSE\n[react-native-blob-util]: https://www.npmjs.com/package/react-native-blob-util\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpalumickas%2Freact-native-activestorage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjpalumickas%2Freact-native-activestorage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpalumickas%2Freact-native-activestorage/lists"}