2

Video - stream - this works.. however on larger files it is slow.. How can I improve the content s3 store to deliver the content faster ?

I have tried returning a byte array and copy to a buffer.. all load.. just slow... I am not sure where the bottle neck is coming from..

  Optional<File> f = filesRepo.findById(id);
        if (f.isPresent()) {
            InputStreamResource inputStreamResource = new InputStreamResource(contentStore.getContent(f.get()));
            HttpHeaders headers = new HttpHeaders();
            headers.setContentLength(f.get().getContentLength());
            headers.set("Content-Type", f.get().getMimeType());
            return new ResponseEntity<Object>(inputStreamResource, headers, HttpStatus.OK);
        }

also get this warning: Not all bytes were read from the S3ObjectInputStream, aborting HTTP connection. This is likely an error and may result in sub-optimal behavior. Request only the bytes you need via a ranged GET or drain the input stream after use.

Coder
  • 21
  • 2
  • https://www.findjar.com/jar/com/github/paulcwarren/spring-content-s3/0.0.5/spring-content-s3-0.0.5.jar.html found this... trying it now... hope this helps someone.. – Coder Mar 29 '21 at 01:01
  • If that helps you, try answering your question. Wait for couple of days to see if someone comes up with a better answer, and then accept the appropriate answer. Its not an issue eve if you end up accepting your own answer. – Asif Kamran Malick Mar 29 '21 at 08:25
  • Well that helped to import the correct libs.. but now can't get it to find the bucket.. updated the question.. – Coder Mar 29 '21 at 18:41
  • now having this new issue.. slow loading of the video.. – Coder Mar 31 '21 at 16:06
  • 1
    Given you are return a ResponseEntity you trying to stream video over a REST endpoint I assume? Are you aware that there is a separate module spring-content-rest that adds content-related endpoints for you so you don't have to do this yourself. These endpoints also support byte-ranges that support standard video playback controls which the above code won't do. – Paul Warren Apr 02 '21 at 05:43
  • Thank you @PaulWarren – Coder Apr 07 '21 at 20:18

0 Answers0