You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: accept urlToPath callback for people without URL.pathname polyfill (#25)
RN's default URL polyfill might not provide `.pathname`, which we use to extract file extnensions.
Instead of requiring everyone to use a polyfill in their app, we instead now take an optional
`urlToPath` callback which is used to extract file extensions. If it's not provided, then files
will be saved without extensions.
BREAKING CHANGE: The default behavior is now changed to not save files with extensions. To make this
change not-breaking would have required that this package accept and use a polyfill for URL, which
feels like it could cause greater problems for people who already use other polyfills.
fix#23
Copy file name to clipboardExpand all lines: README.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -71,6 +71,7 @@ You can pass any of the following options, or nothing at all:
71
71
|---|---|---|---|
72
72
|handlers|DownloadQueueHandlers|undefined|For any events you'd like to receive notifications about, you'll need to pass a handler here. More details in the next table.|
73
73
|domain|string|"main"|By default, AsyncStorage keys and RNFS filenames are with DownloadQueue/main". If you want to use something other than "main", pass it here. This is commonly used to manage different queues for different users (e.g. you can use userId as the domain).|
74
+
|urlToPath|(url:string) => string|undefined (i.e. files will be saved without extensions)|Callback used to get a pathname from a URL. By default, files are saved without any particular extension. But if you need the server extension to be preserved (e.g. you pass the file to a media player that uses the extension to determine its data format), pass a function here that returns a path given a URL (e.g. for `https://foo.com/baz/moo.mp3?q=song`, returns `baz/moo.mp3`). The easiest way to implement this if you already have a React Native URL polyfill is: `(url) => new URL(url).pathname`. If you don't have a polyfill, you can use something like https://www.npmjs.com/package/react-native-url-polyfill|
74
75
|startActive|boolean|true|Whethertostartthequeueinanactivestatewheredownloadswillbestarted. Iffalse, no downloads will begin until you call resumeAll().|
75
76
|netInfoAddEventListener|(listener: (state: {isConnected:boolean \|null, type:string}) =>void) => ()=>void|undefined|Ifyou'd like DownloadQueue to pause downloads when the device is offline, pass this. Usually easiest to literally pass `NetInfo.addEventListener`.|
76
77
|activeNetworkTypes| string[] | [] |The NetInfoStateType values for which downloads will be allowed. If you pass undefined or [], downloads will happen on all connection types. A common practice is to pass ["wifi", "ethernet"] if you want to help users avoid cellular data charges. As of @react-native-community/[email protected], valid values are "unknown", "none", "wifi", "cellular", "bluetooth", "ethernet", "wimax", "vpn", "other", "mixed".|
0 commit comments