{"id":20775899,"url":"https://github.com/kathawala/expo-file-dl","last_synced_at":"2025-07-22T18:33:48.931Z","repository":{"id":42409694,"uuid":"310806031","full_name":"kathawala/expo-file-dl","owner":"kathawala","description":"Download files to any folder and notify the user while the download is happening and when the download finishes","archived":false,"fork":false,"pushed_at":"2022-04-06T21:47:59.000Z","size":764,"stargazers_count":45,"open_issues_count":12,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-15T02:39:55.107Z","etag":null,"topics":["expo","expo-file-download","expo-notifications","expo-sdk","file-download","package","react-native","react-native-file-download","typescript"],"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/kathawala.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}},"created_at":"2020-11-07T09:05:46.000Z","updated_at":"2025-04-22T12:19:19.000Z","dependencies_parsed_at":"2022-08-04T11:30:18.474Z","dependency_job_id":null,"html_url":"https://github.com/kathawala/expo-file-dl","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/kathawala/expo-file-dl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kathawala%2Fexpo-file-dl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kathawala%2Fexpo-file-dl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kathawala%2Fexpo-file-dl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kathawala%2Fexpo-file-dl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kathawala","download_url":"https://codeload.github.com/kathawala/expo-file-dl/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kathawala%2Fexpo-file-dl/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265564256,"owners_count":23788845,"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":["expo","expo-file-download","expo-notifications","expo-sdk","file-download","package","react-native","react-native-file-download","typescript"],"created_at":"2024-11-17T12:39:47.645Z","updated_at":"2025-07-22T18:33:48.862Z","avatar_url":"https://github.com/kathawala.png","language":"TypeScript","funding_links":["https://liberapay.com/kathawala/donate","https://www.paypal.com/cgi-bin/webscr?cmd=_donations\u0026business=LHG78XBMVTU82\u0026item_name=open+source+software\u0026currency_code=USD"],"categories":[],"sub_categories":[],"readme":"\u003c!-- Add banner here --\u003e\n![banner](https://storage.googleapis.com/gh-assets/expo-file-dl.png)\n\n\u003c!-- omit in toc --\u003e\n# expo-file-dl\n\n\u003c!-- Add buttons here --\u003e\n![GitHub last commit](https://img.shields.io/github/last-commit/kathawala/expo-file-dl)\n![npm version](https://img.shields.io/npm/v/expo-file-dl)\n![npm downloads weekly](https://img.shields.io/npm/dw/expo-file-dl)\n\n\u003c!-- Describe your project in brief --\u003e\nA library which allows you to download files to an arbitrary folder on the mobile device while updating you on the download progress and displaying notifications to the user about the status of the file download. Downloading files to a folder in Expo isn't super-obvious so this library is meant to bridge the gap a bit.\nTo use this library you need to be using `expo-notifications` (bare and managed workflow both supported) and need to have the following in your app:\n\n1. An existing notification channel\n2. A notification-handler function\n3. `CAMERA_ROLL` permissions granted by the user\n\n\u003c!-- Some badges that you could use --\u003e\n\n\u003c!-- ![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/navendu-pottekkat/awesome-readme?include_prereleases)\n: This badge shows the version of the current release.\n\n![GitHub issues](https://img.shields.io/github/issues-raw/navendu-pottekkat/awesome-readme)\n: This is a dynamic badge from [**Shields IO**](https://shields.io/) that tracks issues in your project and gets updated automatically. It gives the user an idea about the issues and they can just click the badge to view the issues.\n\n![GitHub pull requests](https://img.shields.io/github/issues-pr/navendu-pottekkat/awesome-readme)\n: This is also a dynamic badge that tracks pull requests. This notifies the maintainers of the project when a new pull request comes.\n\n![GitHub All Releases](https://img.shields.io/github/downloads/navendu-pottekkat/awesome-readme/total): If you are not like me and your project gets a lot of downloads(*I envy you*) then you should have a badge that shows the number of downloads! This lets others know how **Awesome** your project is and is worth contributing to.\n\n![GitHub](https://img.shields.io/github/license/navendu-pottekkat/awesome-readme)\n: This shows what kind of open-source license your project uses. This is good idea as it lets people know how they can use your project for themselves.\n\n![Tweet](https://img.shields.io/twitter/url?style=flat-square\u0026logo=twitter\u0026url=https%3A%2F%2Fnavendu.me%2Fnsfw-filter%2Findex.html): This is not essential but it is a cool way to let others know about your project! Clicking this button automatically opens twitter and writes a tweet about your project and link to it. All the user has to do is to click tweet. Isn't that neat? --\u003e\n\n\u003c!-- omit in toc --\u003e\n# Demo-Preview\n\n![screencap](https://storage.googleapis.com/gh-assets/managed.gif)\n\n# Table of contents\n\n\u003c!-- After you have introduced your project, it is a good idea to add a **Table of contents** or **TOC** as **cool** people say it. This would make it easier for people to navigate through your README and find exactly what they are looking for.\n\nHere is a sample TOC(*wow! such cool!*) that is actually the TOC for this README. --\u003e\n\n- [Table of contents](#table-of-contents)\n- [Installation](#installation)\n  - [Managed Expo project](#managed-expo-project)\n  - [Bare Expo project or plain React-Native project](#bare-expo-project-or-plain-react-native-project)\n- [Usage](#usage)\n  - [downloadToFolder](#downloadtofolder)\n- [Development](#development)\n- [Contribute](#contribute)\n    - [Sponsor](#sponsor)\n      - [Liberapay](#liberapay)\n      - [PayPal](#paypal)\n    - [Adding new features or fixing bugs](#adding-new-features-or-fixing-bugs)\n\n# Installation\n[(Back to top)](#table-of-contents)\n\n## Managed Expo project\n\nJust run\n\n```\nyarn add expo-file-dl\n```\n\n## Bare Expo project or plain React-Native project\n\nFirst, you need to install `react-native-unimodules` if you haven't already.\nFollow [these instructions](https://docs.expo.io/bare/installing-unimodules/) to do so.\n\nThen, add `android:requestLegacyExternalStorage=\"true\"` to your `AndroidManifest.xml` like so\n\n```xml\n\u003cmanifest ... \u003e\n  \u003capplication android:requestLegacyExternalStorage=\"true\" ... \u003e\n    ...\n  \u003c/application\u003e\n\u003c/manifest\u003e\n```\n\nThen add this to your `app.json` file\n\n```\n{\n  \"expo\": {\n    ...\n    \"android\": {\n      ...\n      \"useNextNotificationsApi\": true,\n    }\n  }\n}\n```\n\nFinally, run\n\n```\nyarn add expo-file-dl\n```\n\n# Usage\n[(Back to top)](#table-of-contents)\n\nTo see a full-code working example, you can check out this example app: [expo-file-dl-example](https://github.com/kathawala/expo-file-dl-example)\n\nThere is a `bare` branch which has a working app using the bare workflow in addition to the `master` branch which uses the managed workflow\n\nTo use the following functions, you need to have:\n\n1. created a `NotificationChannel` using `Notifications.setNotificationChannelAsync` ([docs](https://docs.expo.io/versions/v39.0.0/sdk/notifications/#setnotificationchannelasyncidentifier-string-channel-notificationchannelinput-promisenotificationchannel--null))\n2. set up a `NotificationHandler` using `Notifications.setNotificationHandler` ([docs](https://docs.expo.io/versions/v39.0.0/sdk/notifications/#setnotificationchannelasyncidentifier-string-channel-notificationchannelinput-promisenotificationchannel--null))\n3. been granted `CAMERA_ROLL` permissions by the user, multiple ways to do this, one way is through `Permissions.askAsync(Permissions.CAMERA_ROLL)` ([docs](https://docs.expo.io/versions/v39.0.0/sdk/permissions/#permissionsaskasynctypes))\n\n## downloadToFolder\n\nsimplest invocation\n\n```jsx\nimport { downloadToFolder } from 'expo-file-dl';\n\n...\n\n      \u003cButton title='Download' onPress={async () =\u003e {\n        await downloadToFolder(uri, filename, folder, channelId);\n      }}\n\n```\n\nwith configuration options\n\n```jsx\nimport { downloadToFolder } from 'expo-file-dl';\n\n...\n\n      \u003cButton title='Download' onPress={async () =\u003e {\n        await downloadToFolder(\n          uri,\n          filename,\n          folder,\n          channelId,\n          {\n            notificationType: {notification: 'custom'},\n            notificationContent: {\n              downloading: {\n                title: 'Download In Progress',\n              },\n              finished: {\n                title: 'Complete!',\n              },\n              error: {\n                title: 'Oops!'\n              },\n            },\n            downloadProgressCallback: (data) =\u003e {\n              const {totalBytesWritten, totalBytesExpectedToWrite} = data;\n              const pctg = 100 * (totalBytesWritten / totalBytesExpectedToWrite);\n              setProgressPercentage(`${pctg.toFixed(0)}%`);\n            },\n          }\n        );\n      }}\n\n```\n\nArguments:\n* `uri`: `string` - the URI of the resource you want to download, currently handles images, videos, and audio well, unsure about other types of resources\n* `filename`: `string` - the filename to save the resource to (only the filename, no path information)\n* `folder`: `string` - the name of the folder on the device to save the resource to, if the folder does not exist it will be created\n* `channelId`: `string` - the id of the NotificationChannel you created earlier\n* `options`: `object` - Optional argument. an object containing any (or none) of the following configurable options:\n  * `notificationType`?: `{ notification: \"managed\" | \"custom\" | \"none\" }` - Optional argument. The managed type uses set defaults for any and all notifications sent during file download. You can override these defaults with `{ notification: \"custom\" }` and you can opt out of sending notifications altogether with `{ notification: \"none\" }`\n  * `notificationContent`?: `{ downloading: NotificationContentInput, finished: NotificationContentInput, error: NotificationContentInput }` - Optional argument, only looked at if `notificationType` is set to `{ notification: \"custom\" }` otherwise it is ignored. See the [docs](https://docs.expo.io/versions/v39.0.0/sdk/notifications/#notificationcontentinput) for `NotificationContentInput` to see what options are available to customize\n  * `downloadProgressCallback`?: `({totalBytesWritten: number, totalBytesExpectedToWrite: number}) =\u003e void` - Optional argument, gets called on every file write to the system with information about how much of the file has been written and how much is left to write.\n\nThis function will download a file from the given URI to a file in the folder with the given name (and will create a folder with the given name if none currently exists). This downloaded file will be visible from other apps, including multimedia apps and file managers. While the download is occurring the user will receive status notifications.\n\nPlease see [expo-file-dl-example](https://github.com/kathawala/expo-file-dl-example) for a working example of this function in action\n\n\n# Development\n[(Back to top)](#table-of-contents)\n\nThe recommended way to work on this app is the following:\n\nClone this repo and install dependencies\n\n```\ngit clone https://github.com/kathawala/expo-file-dl.git\ncd expo-file-dl\nyarn install\n```\n\nClone the `expo-file-dl-example` repo and install dependencies\n\n```\ngit clone https://github.com/kathawala/expo-file-dl-example.git\ncd expo-file-dl-example\nyarn install\n```\n\nChange `package.json` in the `expo-file-dl-example` code to point to the local copy of `expo-file-dl`\n\n**package.json**\n```\n{\n    ...\n    \"dependencies\": {\n        ...\n        \"expo-file-dl\": \"../expo-file-dl\",\n        ...\n    }\n    ...\n}\n```\n\nNow you can make changes to `expo-file-dl`. When you want to test them out, go to the `expo-file-dl-example` directory and start the expo server\n\n(if you don't have `expo` run `yarn add global expo-cli`)\n```\ncd ../expo-file-dl-example\nexpo start\n```\n\nAnd you can test the changes on your phone or emulator\n\n# Contribute\n\n### Sponsor\n[(Back to top)](#table-of-contents)\n\nIf this saved you development time or you otherwise found it useful, leave a star or follow in GitHub.\n\nYou can also buy me a coffee to say thanks:\n\n\u003c!-- Liberapay --\u003e\n#### Liberapay\n\u003ca href=\"https://liberapay.com/kathawala/donate\"\u003e\u003cimg alt=\"Donate using Liberapay\" src=\"https://liberapay.com/assets/widgets/donate.svg\"\u003e\u003c/a\u003e\n\n\u003c!-- PayPal --\u003e\n#### PayPal\n[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations\u0026business=LHG78XBMVTU82\u0026item_name=open+source+software\u0026currency_code=USD)\n\n### Adding new features or fixing bugs\n[(Back to top)](#table-of-contents)\n\nFollow the [instructions above](#development) if you want to set up the environment to write a PR\n\nBug reports are also welcome, please provide a minimum reproducible example along with a bug report\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkathawala%2Fexpo-file-dl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkathawala%2Fexpo-file-dl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkathawala%2Fexpo-file-dl/lists"}