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

Resumable video uploads #3933

Merged
merged 63 commits into from
May 10, 2021

Conversation

kontrollanten
Copy link
Contributor

@kontrollanten kontrollanten commented Apr 7, 2021

Description

Make audio/video uploads resumable when the internet connection is flaky. This is done by using node-uploadx and ngx-upload. This family of libraries supports multiple operations modes (TUS v1.0, a Google Resumable v3.0 variant and multipart). We selected the default mode, which is using a variant of Google Resumable (used in Drive and YouTube upload endpoints) and is summarized here: https://github.com/kukhariev/node-uploadx/blob/master/proto.md

/api/v1/videos/upload was left untouched.
/api/v1/videos/upload-resumable was created and dedicated to this new upload method.

The OpenAPI spec was modified to include the new upload API.

Related issues

closes #324
kukhariev/node-uploadx#318

Has this been tested?

  • 👍 yes, I added tests to the test suite
    • video upload
    • audio upload

Screenshots

Resume video upload

Copy link
Collaborator

@rigelk rigelk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kontrollanten thanks for taking care of this issue! I didn't review much the backend, but will check more thoroughly once the PR leaves its draft state.

client/package.json Outdated Show resolved Hide resolved
server/controllers/api/videos/index.ts Outdated Show resolved Hide resolved
@rigelk
Copy link
Collaborator

rigelk commented Apr 7, 2021

@kontrollanten btw if you need help for the implementation (like tests or tmp cleanup as job), I can give you a hand.

@kontrollanten
Copy link
Contributor Author

@kontrollanten btw if you need help for the implementation (like tests or tmp cleanup as job), I can give you a hand.

Thanks. I'm thinking about what the best solution is for the server tests that are using the shared/extra-utils/videos/uploadVideo function. In one way the new upload process is an implementation detail that are out of scope for our testing purpose, but in the other way we need an easy way to upload videos in the tests. But to rewrite the logic from ngx-uploadx just for testing purpose feels overkill.

@rigelk
Copy link
Collaborator

rigelk commented Apr 15, 2021

It seems node-uploadx has been updated with the required changes to further this PR: https://github.com/kukhariev/node-uploadx/releases/tag/v4.3.0

@kontrollanten kontrollanten marked this pull request as ready for review April 16, 2021 13:08
rigelk
rigelk previously requested changes Apr 16, 2021
server/helpers/custom-validators/videos.ts Outdated Show resolved Hide resolved
server/controllers/api/videos/index.ts Outdated Show resolved Hide resolved
server/controllers/api/videos/index.ts Outdated Show resolved Hide resolved
server/controllers/api/videos/index.ts Outdated Show resolved Hide resolved
server/controllers/api/videos/index.ts Outdated Show resolved Hide resolved
server/controllers/api/videos/index.ts Outdated Show resolved Hide resolved
server/middlewares/validators/videos/videos.ts Outdated Show resolved Hide resolved
server/controllers/api/videos/index.ts Outdated Show resolved Hide resolved
@kontrollanten kontrollanten requested a review from rigelk April 17, 2021 05:47
@rigelk rigelk force-pushed the feat-324-resume-upload branch from 44c1187 to 4082bc0 Compare April 17, 2021 15:24
@rigelk rigelk dismissed their stale review April 17, 2021 15:25

PR changed sufficiently to require a re-evaluation

@rigelk rigelk added the Status: Requires Tests Either requires manual test, or writing tests, or both label Apr 17, 2021
@rigelk
Copy link
Collaborator

rigelk commented Apr 17, 2021

@kontrollanten I rebased and moved your code to upload-resumable, and restored the upload route. This prevents removing from the API blueprint, and also allows us to not break tests at the same time as we add new ones.

@rigelk rigelk removed the Status: Requires Tests Either requires manual test, or writing tests, or both label Apr 18, 2021
@kontrollanten
Copy link
Contributor Author

Thanks @rigelk ! What do we got left to be able to merge this? Tests and a cleanup job for /tmp? If you haven't started on the cleanup job I think I can do that. I that it should be a repeat job that runs once an hour.

@rigelk
Copy link
Collaborator

rigelk commented Apr 19, 2021

Tests and a cleanup job for /tmp?

Yes, and I'd like to cleanup the object passing (file, metadata) which is brittle at the moment. Having well-typed object passing there is important, and especially regarding the plugin hook which receives the object.

As for tests, we need to try not as much as the legacy upload, but at least the audio-only resumable upload, which is handled very differently from the rest within the middleware.

package.json Outdated Show resolved Hide resolved
@kontrollanten
Copy link
Contributor Author

It looks like the cleanup job fails to run in the tests, but I've no idea how to debug.

server/helpers/utils.ts Outdated Show resolved Hide resolved
@rigelk rigelk force-pushed the feat-324-resume-upload branch 2 times, most recently from 1952fa1 to c2ddc93 Compare April 20, 2021 11:12
@rigelk rigelk requested a review from Chocobozzz April 20, 2021 11:42
Copy link
Owner

@Chocobozzz Chocobozzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

server/controllers/api/videos/index.ts Outdated Show resolved Hide resolved
server/helpers/utils.ts Outdated Show resolved Hide resolved
server/helpers/utils.ts Outdated Show resolved Hide resolved
server/initializers/constants.ts Outdated Show resolved Hide resolved
server/controllers/api/videos/index.ts Outdated Show resolved Hide resolved
server/controllers/api/videos/index.ts Outdated Show resolved Hide resolved
server/controllers/api/videos/index.ts Outdated Show resolved Hide resolved
server/controllers/api/videos/index.ts Outdated Show resolved Hide resolved
server/controllers/api/videos/index.ts Outdated Show resolved Hide resolved
@rigelk rigelk force-pushed the feat-324-resume-upload branch from bc440f3 to 40473ad Compare April 21, 2021 19:12
@rigelk rigelk requested a review from Chocobozzz April 21, 2021 19:45
@rigelk rigelk force-pushed the feat-324-resume-upload branch from 826b7ce to 2a5d59d Compare April 22, 2021 11:34
@rigelk rigelk force-pushed the feat-324-resume-upload branch from f16f236 to 4951b3b Compare April 29, 2021 14:06
@rigelk rigelk dismissed their stale review April 29, 2021 14:10

requested changes covered now refactored code

@Chocobozzz Chocobozzz self-assigned this May 4, 2021
@Chocobozzz
Copy link
Owner

PR is ready, waiting for kukhariev/node-uploadx#337

@Chocobozzz
Copy link
Owner

Thanks @rigelk @kontrollanten and @kukhariev for your work and reactivity

@Chocobozzz Chocobozzz merged commit f6d6e7f into Chocobozzz:develop May 10, 2021
@kontrollanten kontrollanten deleted the feat-324-resume-upload branch May 10, 2021 13:19
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.

Allow uploads to be resumed
4 participants