I was trying to write a React JS code that would download gzip - file from server once per day, and if the file was already downloaded today - use the downloaded one.
The code for downloading files was pretty easy and it works.
import FileSaver from 'file-saver'
const today = () => (new Date().toISOString().slice(0, 10))
const schedules = () => concat(
...config.epgUrls.map(
(url) =>
ajax({
url,
method: 'GET',
responseType: 'blob'
})
)
)
export const saveChannelsEpic =
(action$) =>
action$.pipe(
ofType(SAVE_CHANNELS),
mergeMap(
() =>
schedules()
.pipe(
pluck('response'),
map((gzipped) => FileSaver.saveAs(gzipped, `${today()}.gz`)),
map(() => saveChannelsFulfilled()),
catchError((err) => {
console.table(err.message)
saveChannelsFailed(err.message)
return EMPTY
})
)
)
)
The problem begins when I want to read it from filesystem (actually from browser's Downloads folder). Could anyone please advise? I know that browsers are restricted to access filesystem, but is there any workaround? I mean accessing 'file://C:/Users/MyUser/Downloads/*.gz' or something like this.
p.s. I would gladly store the file in localStorage, but there appears to be a limit ~ 8 MB. My files are ~100MB unzipped and ~20MB gzipped.