Return the permanent url from generate_url - #103
Open
lalit-videodb wants to merge 1 commit into
Open
Conversation
Generated assets only ever had a signed url with the expiry baked in - 6 days for images, 7 for audio. Callers store what generate_url returns, so the link dies and nothing can renew it. The server now gives each asset a permanent url. Prefer it, and keep the signed url as a fallback for assets that predate it. Note the returned url is a redirect rather than a direct storage url: fetch it with a client that follows redirects, and a HEAD returns the redirect's content-length rather than the object's. Audio gained the url attribute; Image already had it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Generated images and audio only ever had one address: a signed storage URL with the expiry baked in — 6 days for images, 7 for audio. Callers store what
generate_url()returns (the Director writes it into chat history), so on day 6 the link starts 403ing and nothing can renew it. Linear ENG-1278.The server side is deployed on dev: each image and audio asset now has a permanent
urlthat resolves through a redirect to a URL signed on the spot, so what we hand out never carries an expiry of its own.This makes
generate_url()prefer that permanent url, falling back to the signed one for assets created before it existed. Doing it here rather than asking callers to switch to.urlfixes the whole install base without anyone editing code — and skips a round trip that is limit-checked at 10k/month per user.Imagealready had aurlattribute;Audiodid not and gains one.Behaviour change — worth a version bump, not a silent swap
The returned url is now a redirect rather than a direct storage url. Verified against dev:
requests, browsers, ffmpeg). A barecurlwithout-Lis not.HEADreturns the redirect'scontent-length(~2.3KB), not the object's size. Anything sizing a file that way silently gets a wrong number.Not a regression: CORS. The old url had no
Access-Control-Allow-Origineither, sofetch()was already blocked both ways.Tested against dev
Fetching one of those returns
content-type: audio/mpegwithcontent-disposition: inline; filename="Permanent Asset Links Live.mp3", and the signature behind it lives ~7 hours instead of 6–7 days.Server PRs, both merged and deployed to dev: Spext/videodb-server#953 and Spext/storage_core#162.