Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Q] Fetch #13

Open
sayem314 opened this issue Apr 8, 2021 · 15 comments
Open

[Q] Fetch #13

sayem314 opened this issue Apr 8, 2021 · 15 comments
Labels
enhancement New feature or request

Comments

@sayem314
Copy link

sayem314 commented Apr 8, 2021

Thanks for the library. I just found it today. I have few questions.

  • Does fetch support background downloads?
  • Is it possible to add pause/resume?
  • Any possibility to add support for download progress?
@alpha0010
Copy link
Owner

The focus of this library is filesystem actions. For more advanced upload/download control, consider https://github.com/edeckers/react-native-blob-courier, it focuses on network, ignoring filesystem, so would compliment this library well.

I have not used react-native-blob-courier myself (so cannot vouch for actual functionality), but from the documentation, appears to handle the features you are looking for.

@sayem314
Copy link
Author

sayem314 commented Apr 9, 2021

Thank you for your response. I will check out the package you mentioned however I would still suggest adding a background download feature with pause and resume since you are providing a fetch option.

@efstathiosntonas
Copy link

efstathiosntonas commented May 7, 2021

Hi @alpha0010, we've recently released https://github.com/georstat/react-native-image-cache, it would be nice to have resumable downloads like: https://github.com/wcandillon/react-native-expo-image-cache/blob/b81b99b01918558c7680595980d76003d507bc6f/src/CacheManager.ts#L29 in order to "improve" it.

We hope/believe that it will get lot of traction.

Thanks

@alpha0010 alpha0010 added the enhancement New feature or request label May 10, 2021
@alpha0010
Copy link
Owner

I looked a bit deeper into this.

Using the system managed downloader might take a bit of work, but should be reasonably straight forward implementation.

App managed pause/resume for downloads would be more complicated. Would need to manage HTTP range requests, and handle servers that do not understand/obey them. On the plus side, this may be possible to implement js/ts side (on top of the existing APIs in this library), so might only need to implement once. Although, native side would be a bit more performant.

Download progress events would need to be emitted from native code for higher resolution. I suppose rough events could be triggered from js if implemented range requests there.

Not currently a priority for me, though I hope to look into at some point. Of course, accepting pull requests if you wish to help.

@efstathiosntonas
Copy link

Thanks for looking into it, I have no clue on native code so I can’t help on this part.

I think everything should be done on native side as you stated. How are the other react native file system libs are handling such cases? (expo fs too)

alpha0010 added a commit that referenced this issue May 16, 2021
@alpha0010
Copy link
Owner

Added progress events in branch https://github.com/alpha0010/react-native-file-access/tree/download-progress . I plan to test a bit more before tagging a release.

@efstathiosntonas
Copy link

Thanks @alpha0010, if you want we can test too with the caching lib in real apps.

alpha0010 added a commit that referenced this issue May 27, 2021
@alpha0010
Copy link
Owner

Thanks. Just published, but of course if you notice any bugs in your testing/use, open an issue here.

Download progress updates live in 1.7.0.

@ezze
Copy link

ezze commented Dec 15, 2021

Unfortunately, react-native-blob-courier doesn't support passing body to fetchBlob at the moment and FileSystem.fetch doesn't support request cancel. So none of both suits our requirements — we need to pass body to fetch request and have an option to cancel it because big amount of data is transferred. Would be awesome if we could add missing options, guys.

@alpha0010
Copy link
Owner

Thanks for your interest. To confirm, passing request body works for you (when using this library), but it is missing request cancel?
Background architecture for supporting cancels is already there. I just ran out of time before wiring it in. Will try to get to that soon.

@ezze
Copy link

ezze commented Dec 15, 2021

@alpha0010 Thanks for reply. Yes, I use your library to download blobs right now because it supports passing a body to request. And I use react-native-blob-courier to upload blobs due to it supports request cancel.

@alpha0010
Copy link
Owner

Published a release; let me know how it works for you.

@ezze
Copy link

ezze commented Dec 17, 2021

@alpha0010 Cool, it was very fast reaction, mate!

But I am sorry, can't test it this time. Already implemented a workaround with react-native-blob-courier suitable for me at the moment. Anyway, I am still using react-native-file-access to work with file system so I'll definitely check it later.

@Nirav-12
Copy link

Thanks for the library.

Any possibility to add support for copy progress ( FileSystem.cp)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants