奇怪个别 jar aliyun maven mirror 没有 ,但是 apache maven 有 问题: 解决: 只能暂时禁用 aliyun mirror , 应该是jar 太新了… Read More
旋转图片 解决: static BufferedImage rotateImg90(BufferedImage image, boolean left) { var ret = new BufferedImage(image.getHeight(), image.getWidth(), image.getType()); Graphics2D g2d = (Graphics2D) ret.getGraphics(); double rotationRequired = Math.toRadians(left ? 90 : -90); double locationX = image.getWidth() / 2; double locationY = image.getHeight() / 2; AffineTransform tx = AffineTransform.getRotateInstance(rotationRequired, locationX, locationY); AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_BILINEAR); g2d.drawImage(image, op, 0, 0); g2d.dispose(); return ret; } 123456789101112 static BufferedImage rotateImg90(BufferedImage image, boolean left) { var ret = new BufferedImage(image.getHeight(), image.getWidth(), image.getType()); Graphics2D g2d = (Graphics2D) ret.getGraphics(); double rotationRequired = Math.toRadians(left ? 90 : -90); double locationX = image.getWidth() / 2; double locationY = image.getHeight() / 2; AffineTransform tx = AffineTransform.getRotateInstance(rotationRequired, locationX, locationY); AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_BILINEAR); g2d.drawImage(image, op, 0, 0); g2d.dispose(); return ret; } 注意 … Read More
Quarkus JAX-RS 上传文件 问题: 解决: public final static class Form1 { @PartType(MediaType.APPLICATION_OCTET_STREAM) @FormParam("file") public InputStream f; } @POST @Consumes(MediaType.MULTIPART_FORM_DATA) public ArticleAttachment upload(@QueryParam("articleId") int articleId, @MultipartForm Form1 form1) throws IOException { System.out.println("articleId:" + articleId); final byte[] d = form1.f.readAllBytes(); System.out.println("f:" + d.length); final File file = new File("a.jpg"); System.out.println("file:" + file.getAbsolutePath()); IOUtils.write(d, new FileOutputStream(file)); return null; } 1234567891011121314151617 public final static class Form1 { @PartType(MediaType.APPLICATION_OCTET_STREAM) @FormParam("file") public InputStream f; } @POST @Consumes(MediaType.MULTIPART_FORM_DATA) public ArticleAttachment upload(@QueryParam("articleId") int articleId, @MultipartForm Form1 form1) throws IOException { System.out.println("articleId:" + articleId); final byte[] d = form1.f.readAllBytes(); System.out.println("f:" + d.length); final File file = new File("a.jpg"); System.out.println("file:" + file.getAbsolutePath()); IOUtils.write(d, new FileOutputStream(file)); return null; } … Read More