How to Implement HTTP byte-range requests in Spring MVC

前端 未结 7 1766
余生分开走
余生分开走 2020-11-30 21:30

I have the problem with video rewind on my site.

I figure out that problem with http headers.

My current controller method which returns video:



        
7条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-30 21:55

    woww, The answer of Leandro so briliant. just create service file follow him and use in controller. here my after follow his guidelines

    @RequestMapping(value = [(SKConstant.URL_PROJECT_API + "/video/{token}")], method = arrayOf(RequestMethod.GET)
    fun getVideo(@PathVariable("token") token: String, response: HttpServletResponse, request: HttpServletRequest): Any?{
             val file = baseService.getByToken(token)
             if(file != null) {
               return MultipartFileSender.fromFile(File(fileService.getUploadFileRealPath(file.uniqueName!!)))
                                  .with(request)
                                  .with(response)
                                  .serveResource()
     }
    

提交回复
热议问题