Include file name in response, and support "Accept" header that contain charset property
This PR has been made to allow clients to use the API with an Accept header defined to application/json; charset=utf-8, which is especially useful for Flutter apps, as they automatically set it instead of the regular application/json.
Additionally, when requesting a download, the API will now return the name of the file. This enhancement aims to improve the developer experience when programmatically accessing Cobalt.
This PR has been made to allow clients to use the API with an
Acceptheader defined toapplication/json; charset=utf-8, which is especially useful for Flutter apps, as they automatically set it instead of the regularapplication/json.
this is a good idea, but if you're going to update this, the check should be (or rather should have been) probably done using req.is for content-type and req.accepts for accept
Additionally, when requesting a download, the API will now return the name of the file. This enhancement aims to improve the developer experience when programmatically accessing Cobalt.
i'm not entirely opposed to it, but I think it would be a better option to simply get the filename from the stream request as an API consumer, since you are usually going to download the stream anyways - if you don't want the data you could probably make a HEAD request (something to check here, if you'd like to contribute a fix, is whether this spawns a ffmpeg process when it's not necessary - i believe it does, but it doesn't need to.)
this is a good idea, but if you're going to update this, the check should be (or rather should have been) probably done using
req.isfor content-type andreq.acceptsfor accept
It seems that req.accepts also refuses Accept header that contains charset and only accepts the application/json value
I think it would be a better option to simply get the filename from the
streamrequest as an API consumer
This would work for stream requests but not for medias that aren't downloaded through the Cobalt backend (such as Twitter, they don't return file names when fetching the media url).
closing this since both parts were re-done are are now implemented