postman测试上传文件
2018-12-19 20:41
525 查看
1.选择post请求方式,输入请求地址
2.填写body
- 选择form-data
- 然后选择文件file
- 点击选择文件,最后发送即可
3.测试结果
4.上传文件接口代码
/** * 文件上传处理类 */ @Controller @RequestMapping(value = "/file") public class FileController { //上传处理 @RequestMapping(value = "/upload",method = RequestMethod.POST) @ResponseBody public WebResult upload(@RequestParam("uploadFile")MultipartFile file) throws Exception { WebResult result = WebResultHelper.newResult(); if (!file.isEmpty()) { //1.取文件格式后缀名 String type = file.getOriginalFilename().substring(file.getOriginalFilename().indexOf(".")); //2.取当前时间戳作为文件名 String fileName = System.currentTimeMillis() + type; //3.设置存放位置 String path = "E:\\代码存档\\springmvc\\springMVC_demo\\src\\main\\java\\com\\steven\\ssm\\upload\\" + fileName; //4.创建文件 File destFile = new File(path); try { //5.复制临时文件到指定目录下 //FileUtils.copyInputStreamToFile()这个方法里对IO进行了自动操作,不需要额外的再去关闭IO流 FileUtils.copyInputStreamToFile(file.getInputStream(), destFile); } catch (IOException e) { e.printStackTrace(); } result.put("message","upload success!"); } else { result.put("message","upload failed!"); } return result; } }
相关文章推荐
- postman测试上传文件
- postman测试文件上传
- postman测试上传文件
- 使用postman测试文件上传
- postman测试文件上传
- curl 测试上传接口,上传图片文件!
- Spring boot 实现文件上传,postman模拟上传文件报错XssHttpServletRequestWrapper cannot be cast to MultipartHttpServle
- 文件上传功能测试的测试点
- 上传图片和导出文件测试用例
- 使用jmeter测试工具完成文件的上传
- Postman Postman测试接口之POST提交本地文件数据
- Postman模拟SpringMVC 文件上传
- 【SoapUI】接口测试之post上传文件方法思路
- 文件上传--测试用例1
- 使用jmeter测试工具完成文件的上传
- 2017-4-24(1493037086057未命名文件 测试资源是否正确上传
- weblogic服务上传word等文件直接打开问题解决 博客分类: web应用服务器 在weblogic上发布的web项目,测试中发现出现当上传word、excel、pdf等文件在下载的时候出现
- Java开发之文件上传 (未测试)
- postman使用csv或json文件批量接口测试
- bugku ctf 文件上传测试