Situation: I have a large set of videos and images and small Play applications, which stores references to the blobs in DB. For web usage that's OK, I'm rendering page, where I put Flowplayer and in it's config I'm using direct blob's path as a source video. Anyway I was asked for additional possibility for other older devices - which should send the file in the response body directly with headers:
Content-Type:video/mp4
Content-disposition:inline
Content-Transfer-Encoding:binary
Originally that solution was done with PHP script, which fetched the blob to the server with the CURL and returned as a response to the client with manipulated header.
Question: What is the best way to do that job with Play? (preferably without downloading file to the server). Blobs will be public, so I don't need to care about hiding original paths, I just need to add headers mentioned above.
- Should I use
WS.url()
to fetch the file to the server and send it as aResult
with modified headers? I tried this, but had some problems withWS
timeouts. - Also tried to set the header
Content-Location:http//mystorage...
, anyway as I understood it requires file in the response body anyway. So maybe there is some other technique with usage of the headers only. - Is there any way to force custom headers while returning direct blob (ie. by setting it in the GET params) ?
Maybe some quite other approach?
I solved my problem with approach no. 1, but with usage of
java.net.URL
instead ofWS.url()
,Bounty promise is actual for better propositions (especially, if it will be done without downloading file to the server).