I have an client written in angular which makes a call to a REST API written in JAVA to retrieve a file. If the file is a video, I have the option to play the video inside the client using a video HTML Tag. The REST API returns a Streaming Output of the file in order not to store the file in memory. For videos shorter than 25 MBs it works fine, but for videos longer than 25 MBs it doesn’t show them. This only happens on Chromium based Browser.
EDIT:
This is the method in the backend, but I highly doubt it is the backend at fault, because I am using the same method both for downloading the file and streaming it directly in a video tag in html.
private DownloadableStream downloadFileNode(String fileId) {
FileNode fileNode = getFileNode(fileId);
String fileName = getFileName(fileId);
StreamingOutput streamingOutput = output -> {
try (OutputStream outputStream = output) {
if (!fileNode.isDownloadable()) {
throw new RuntimeException("cannot download file");
}
processFileContent(fileNode, outputStream); //returns a stream of data from the db
} catch (IOException e) {
throw new RuntimeException("file is not existent")
}
};
return new DownloadableStream(fileName, streamingOutput);
}
And for the frontend part basically what happens is I create a href to this endpoint, and whenever I press the video object in the frontend I expect the video to be loaded inside the HTML video tag.
Again I’ve tried using multiple browsers and only those based on chromium don’t work. At first I thought It was the difference between the headers, I ve tried changing the Accept-encoding header, accept header and range header. I am not sure if connection header could cause this issue, as for some reason whenever I try to change it it stays the same.
--headers for brave--
https
Accept:
*/*
Accept-Encoding:
identity;q=1, *;q=0
Accept-Language:
en-US,en;q=0.6
Cookie:
Range:
bytes=0-
Referer:
https: --url here--
Sec-Ch-Ua:
"Chromium";v="122", "Not(A:Brand";v="24", "Brave";v="122"
Sec-Ch-Ua-Mobile:
?0
Sec-Ch-Ua-Platform:
"Linux"
Sec-Fetch-Dest:
video
Sec-Fetch-Mode:
no-cors
Sec-Fetch-Site:
same-origin
Sec-Gpc:
1
User-Agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36
--headers for firefox--
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0
Accept: video/webm,video/ogg,video/*;q=0.9,application/ogg;q=0.7,audio/*;q=0.6,*/*;q=0.5
Accept-Language: en-US,en;q=0.5
Referer: --url here--
Range: bytes=0-
Connection: keep-alive
Cookie:
Sec-Fetch-Dest: video
Sec-Fetch-Mode: no-cors
Sec-Fetch-Site: same-origin
Accept-Encoding: identity
Priority: u=4
TE: trailers
EDIT2
Also another thing that I noticed is that Brave/Chrome makes two requests when I play the video to the same endpoint, while Firefox only one: The first one which has the same content-disposition for both Firefox and Chrome.
content-disposition
attachment; filename="2019-08-05 14-48-53.mp4"
Ant the second one which doesn’t have any content-disposition is done by chrome and fails.
What could be the reason for this ?
2