We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pom.xml
<dependency> <groupId>org.jodd</groupId> <artifactId>jodd-http</artifactId> <version>5.0.13</version> </dependency>
@Slf4j public class ImageUploadUtilsTests { @Test public void upload() throws IOException { File file = ResourceUtils.getFile("classpath:20180822153319.jpg"); HttpRequest request = HttpRequest .post("http://127.0.0.1:8899/upload") .body(Files.toByteArray(file), suffex(file.getName())) ; HttpResponse response = request.send() .acceptEncoding(Charsets.UTF_8.name()) .contentType(MediaType.APPLICATION_JSON_UTF8_VALUE); ImgResult result = JSON.parseObject(response.bodyText(), ImgResult.class); log.info("===>{}", result); } private static String suffex(String fileName) { return StringUtils.substringAfter(fileName, "."); } @Data static class ImgResult{ private boolean ret; private ImgError error; private ImgInfo info; } @Data static class ImgError{ private int code; private String message; } @Data static class ImgInfo{ private String md5; private long size; } }
返回值:
===>JSON: {"ret":true,"info":{"md5":"2a3d3a3ae4a6d8cce26f8e1b3e7a467d","size":1601925}} ===>ImgResult: ImageUploadUtils.ImgResult(ret=true, error=null, info=ImageUploadUtils.ImgInfo(md5=2a3d3a3ae4a6d8cce26f8e1b3e7a467d, size=1601925))
The text was updated successfully, but these errors were encountered:
No branches or pull requests
pom.xml
返回值:
The text was updated successfully, but these errors were encountered: