fix: use TusAndroidUpload instead of TusUpload#9
fix: use TusAndroidUpload instead of TusUpload#9julianocomg wants to merge 5 commits intovinzscam:masterfrom
Conversation
TusAndroidUpload automatically parses "content://" uris
React native on android doesn't support to much events at a time. This commit fix this issue by sending the current progress on every 500ms.
| File file = new File(fileUrl); | ||
| upload = new TusUpload((file)); | ||
|
|
||
| upload = new TusAndroidUpload(Uri.parse(fileUrl), reactContext); |
There was a problem hiding this comment.
Isn't the second parameter supposed to be of type "Activity" as per the following documentation https://tus.github.io/tus-android-client/javadoc/io/tus/android/client/TusAndroidUpload.html ?
There was a problem hiding this comment.
Yes! I tried with getCurrentActivity() too, but for some reason it was not working properly for me (Xiaomi Mi 9). Then I tried with reactContext instead and it worked great.
There was a problem hiding this comment.
The result is currently in production btw:
https://play.google.com/store/apps/details?id=io.starchive.mobile
| public void run() { | ||
| sendProgressEvent(upload.getSize(), uploader.getOffset()); | ||
| } | ||
| }, 0, 500); |
There was a problem hiding this comment.
maybe we should make the period's value customizable from javascript!
|
|
||
| do {} while (uploader.uploadChunk() > -1 && !shouldFinish); | ||
|
|
||
| sendProgressEvent(upload.getSize(), upload.getSize()); |
There was a problem hiding this comment.
swapping the two methods could avoid some unnecessary progress events' calls:
progressTicker.cancel();
sendProgressEvent(upload.getSize(), upload.getSize());
TusAndroidUpload automatically parse "content://" URIs