文件视频上传

@CrossOrigin
public class FileController {
    @RequestMapping("/upload")
/**
*文件上传
*/
    public String upload(MultipartFile file)throws Exception{
        String filename = UUID.randomUUID().toString().replace("-", "");
        file.transferTo(new File("C:\\Users\\wangliang\\Desktop\\img\\test\\" + filename));
        return filename;
    }
/**
* 视频上传
*/
    @RequestMapping("/show")
    public void show(String fileName, HttpServletResponse response)throws Exception{
        FileInputStream inputStream = new FileInputStream(new File("C:\\Users\\wangliang\\Desktop\\img\\test\\" + fileName));
        ServletOutputStream outputStream = response.getOutputStream();
        byte [] buffer = new byte[1024];
        int len;
        while ((len = inputStream.read(buffer)) != -1){
            outputStream.write(buffer, 0, len);
        }
        outputStream.flush();
        outputStream.close();
        inputStream.close();
    }
}

文件视频上传

上一篇:appium环境666


下一篇:安卓ADB的使用