-
Notifications
You must be signed in to change notification settings - Fork 31
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
api: Implement resumable uploads for VOD #1112
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
9fc7949
to
de13c2d
Compare
de13c2d
to
01da842
Compare
Remember to delete this or make it a proper unit test once it's done.
…ded gcsOptions to schema
Now app-router only needs to call a func
async function createTestTusServer() { | ||
const tusTestServer = new tus.Server(); | ||
tusTestServer.datastore = new tus.FileStore({ | ||
path: "/tmp", |
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.
Might wanna use os.tmpdir()
here instead of the hardcoded /tmp
just for compatibility with non-Unix platforms.
Can also consider using fs.mkdtempSync
to create a folder inside /tmp
just not to pollute devs machines too much. Could be just /tmp/studio-tus
for example to keep everything in there. WDYT?
Found all those functions here: https://blog.mastykarz.nl/create-temp-directory-app-node-js/
But I don't think we need to bother deleting the directory after the tests are done. Seems OK to just write to the same folder every time and the dev can clean it up eventually if desired.
async function createTestTusServer() { | ||
const tusTestServer = new tus.Server(); | ||
tusTestServer.datastore = new tus.FileStore({ | ||
path: "/tmp", |
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.
You're probably missing a namingFunction
here as well. Keep in mind that you can't use the same one as below, since that one creates a file name with a directory, and the FileStore
seemed to not like that when I tested it. You can just inline some function here like
path: "/tmp", | |
path: "/tmp", | |
namingFunction: (req) => req.res.getHeader("livepeer-playback-id").toString(), |
To keep the file name just equal to the playback ID. Then it's also easy on your tests to check if the file was created and is equal to what you sent. WDYT?
Codecov Report
@@ Coverage Diff @@
## master #1112 +/- ##
===================================================
+ Coverage 50.41836% 50.70655% +0.28819%
===================================================
Files 66 66
Lines 4183 4246 +63
Branches 740 748 +8
===================================================
+ Hits 2109 2153 +44
- Misses 1825 1836 +11
- Partials 249 257 +8
Continue to review full report at Codecov.
|
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.
LGTM but I opened the PR so I can't approve 😛
The tests need some fixes though, as it's missing a couple of important checks to ensure proper functioning. Both in the "setup test" logic as well as in the test code itself.
Was missing the tus-js-client dependency and needed to fix the check on URL format.
[DEV] How to test this
packages/api
folder and runyarn dev
packages/tus-test
folder, setLP_API_KEY
env and runyarn start
Useful links
What's missing
The "only" thing we're really missing now is changing the local filesystem storage to a Google Cloud Storage storage,
which is what we use for VOD today. For that it might be necessary to change directUpload file names again, maybe
losing all the folders and just saving something on the root of the bucket like
directUpload-<playbackId>
or the otherway around
<playbackId>-directUpload
just so it has the same prefix as the final asset folder.It may seem like a simple change, but other problems might happen on the way to switching the storage. Let's just hope
that not too many.