How to return a video to postman

Asked by At

I'm doing a project of mine something like lets say youtube I've done the uploading videos part but I'm stuck on how can I playback those videos to Postman?

I've tried making the return type MultipartFile class and just returning the file but it doesn't seems to work.

public class VideoController {
    @PostMapping(value = "/upload")
    public void uploadVideo(@RequestParam("video") MultipartFile file) throws IOException {

        byte[] bytes = file.getBytes();
        File newVideo = new File("D:\\test\\" + file.getName() + ".mp4");
        FileOutputStream fos = new FileOutputStream(newVideo);

1 Answers

Paul Warren On Best Solutions

I don't think Postman support video streaming. Regardless, in order to stream video your VideoController would need to have a GetMapping method that supports range requests which is a non-trivial coding task.

You should take a look at the community project Spring Content. This project is an abstraction over Storage and provides a range of Storage implementations including the good old Filesystem. Importantly, it also supports video streaming out of the box as this post describes.

NB: Current version of Spring Content is 0.8.0.