-
Notifications
You must be signed in to change notification settings - Fork 32
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
fix: use TusAndroidUpload instead of TusUpload #9
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
swapping the two methods could avoid some unnecessary progress events' calls:
progressTicker.cancel();
sendProgressEvent(upload.getSize(), upload.getSize());
TusAndroidUpload automatically parse "content://" URIs