micronaut-core icon indicating copy to clipboard operation
micronaut-core copied to clipboard

Support for HTTP 206 Partial Content for serving SystemFile

Open Ksnz opened this issue 2 years ago • 0 comments

Feature description

Current NettySystemFileCustomizableResponseType implementation does not support partial content. Its support may be useful for building something like a video streaming service. I made my own implementation of NettyFileCustomizableResponseType based on copy-paste from NettySystemFileCustomizableResponseType https://gist.github.com/Ksnz/b2a223262514fe77218d481aa7ed6d96 And now endpoint wrapped into it like

    @Get(value = "{id}", produces = MediaType.ALL)
    public ByteRangeSupportNettySystemFileCustomizableResponseType fetchPreview(@PathVariable UUID id)
    {
        ...
        return new ByteRangeSupportNettySystemFileCustomizableResponseType(new SystemFile(file));
    }

supports requests with byte-range.

My implementation isn't perfect because I just need to solve a problem and have no clue how to properly deal with invalid range exceptions. So it requires some refactoring to be used in framework.

Ksnz avatar Aug 22 '22 09:08 Ksnz