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

vod: specify content-length when creating presigned urls #1921

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gioelecerati
Copy link
Member

@gioelecerati gioelecerati commented Oct 14, 2023

What does this pull request do? Explain your changes. (required)

This is coming out of nothing, just a thing that came to my mind.

With this, we allow developers to specify a contentLength parameter in the request-upload api that generates presigned URLs.
This way, that URL is going to be valid exclusively for files with that exact size in bytes.

This enables tier enforcing for platforms, for example, a platform providing free tier functionalities with a max asset size of 50MB for users would generate the presigned URL in the backend collecting the content-length of the user file and providing it to our function.

If the user tries to upload a different file, a 403 status code would get returned.

Specific updates (required)

How did you test each of these updates (required)

Does this pull request close any open issues?

Screenshots (optional)

Checklist

  • I have read the CONTRIBUTING document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.

@vercel
Copy link

vercel bot commented Oct 14, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
livepeer-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 14, 2023 2:22pm

@gioelecerati gioelecerati force-pushed the gio/vod/content-length-presigned-url branch from 6732165 to 1984ac9 Compare October 14, 2023 14:16
@gioelecerati gioelecerati marked this pull request as ready for review October 14, 2023 14:16
@gioelecerati gioelecerati requested a review from a team as a code owner October 14, 2023 14:16
Copy link
Member

@victorges victorges left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +1074 to +1081
if (!res.headersSent) {
res.status(403);
res.end();
proxyRes.end();
} else {
res.end();
proxyRes.end();
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (!res.headersSent) {
res.status(403);
res.end();
proxyRes.end();
} else {
res.end();
proxyRes.end();
}
if (!res.headersSent) {
res.status(403);
}
res.end();
proxyRes.end();

proxy.on("error", function (err, req, proxyRes) {
console.error("Proxy error:", err);
if (!res.headersSent) {
res.status(403);
Copy link
Member

Choose a reason for hiding this comment

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

would this work?

Suggested change
res.status(403);
res.status(proxyRes.status);

Bucket: config.bucket,
Key: objectKey,
});
ContentLength: null,
Copy link
Member

Choose a reason for hiding this comment

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

Could be just ContentLength: contentLength || null

Comment on lines +923 to +924
contentLength:
type: number
Copy link
Member

Choose a reason for hiding this comment

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

This should be in api-schema since its public

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.

None yet

2 participants