Skip to content

fix: use TusAndroidUpload instead of TusUpload#9

Open
julianocomg wants to merge 5 commits intovinzscam:masterfrom
digitalrelab:master
Open

fix: use TusAndroidUpload instead of TusUpload#9
julianocomg wants to merge 5 commits intovinzscam:masterfrom
digitalrelab:master

Conversation

@julianocomg
Copy link

TusAndroidUpload automatically parse "content://" URIs

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);

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 ?

Copy link
Author

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.

Copy link
Author

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);
Copy link
Owner

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());
Copy link
Owner

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());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants