Skip to content

Download files to the public Download folder on Android

Notifications You must be signed in to change notification settings

SimpliField/filesaver

Repository files navigation

filesaver

Allows saving files to a scoped storage on Android 10+

Install

npm install filesaver
npx cap sync

for open intent res/file_path.xml

don't forget to add provider after package name in authorities <provider android:name="androidx.core.content.FileProvider" android:authorities="com.example.androidlldownloadandviewfile.provider" android: exported="false" android: granturiPermissions="true"

<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource."@xml/file_path" />

API

saveToDownloads(...)

saveToDownloads(options: { url: string; fileName: string; }) => Promise<{ downloadId: number; }>
Param Type
options { url: string; fileName: string; }

Returns: Promise<{ downloadId: number; }>


stopDownload(...)

stopDownload(options: { id: number; }) => Promise<void>
Param Type
options { id: number; }