Commit 280410ec authored by huangcb's avatar huangcb

上传文件增加word文件支持

parent 2a90a562
......@@ -52,7 +52,7 @@ aes:
key: freight-file-servie-3.1415926535
#文件下载基础url
file:
register: image=2,pdf=10,excel=5,apk=100
register: image=2,pdf=10,excel=5,word=5,apk=100
download:
base-url: http://127.0.0.1:8002/file/download/direct/
baidu:
......
......@@ -52,7 +52,7 @@ aes:
key: freight-file-servie-3.1415926535
#文件下载基础url
file:
register: image=2,pdf=10,excel=5,apk=100
register: image=2,pdf=10,excel=5,word=5,apk=100
download:
base-url: http://192.168.31.248:8082/file/download/direct/
baidu:
......
......@@ -71,6 +71,35 @@ public class UploadControllerTest extends BaseTestController {
fileUrl = result.getJSONObject("data").getString("url");
}
@Test
public void a2_uploadSingleFile_pdf_success_test() throws Exception {
String url = "/upload/single";
JSONObject reqJson = new JSONObject();
// 构造数据
String filepath = "D:\\test\\线下合同-货主.pdf";
File file = new File(filepath);
InputStream input = new FileInputStream(file);
reqJson.put("fileType", "pdf");
reqJson.put("fileData", Base64.getEncoder().encodeToString(IOUtils.toByteArray(input)));
reqJson.put("fileName", "线下合同-货主");
MvcResult mvcResult = this.getMockMvc().perform(MockMvcRequestBuilders.post(url)
.contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
.content(reqJson.toJSONString()))
.andDo(MockMvcResultHandlers.print())
.andExpect(MockMvcResultMatchers.status().isOk())
.andReturn();
String responseStr = mvcResult.getResponse().getContentAsString();
log.info(responseStr);
JSONObject result = JSONObject.parseObject(responseStr);
Assert.assertEquals(ECode.SUCCESS.code(), result.getIntValue("code"));
fileId = result.getJSONObject("data").getString("id");
fileUrl = result.getJSONObject("data").getString("url");
}
@Test
public void b1_uploadSingleFile_file_type_error_test() throws Exception {
String url = "/upload/single";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment