From 6d55325fc7b273b99406db69eb1a08c036bfc04d Mon Sep 17 00:00:00 2001 From: LamGC Date: Fri, 10 Jul 2020 09:53:41 +0800 Subject: [PATCH] =?UTF-8?q?[Fix]=20PixivUgoiraBuilder=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?ZipInputStream=E5=9C=A8=E8=AF=BB=E5=8F=96=E5=AE=8C=E7=AC=AC?= =?UTF-8?q?=E4=B8=80=E5=B8=A7=E5=9B=BE=E5=83=8F=E5=90=8E=E8=A2=AB=E6=84=8F?= =?UTF-8?q?=E5=A4=96=E5=85=B3=E9=97=AD=E7=9A=84=E9=97=AE=E9=A2=98;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/net/lamgc/cgj/pixiv/PixivUgoiraBuilder.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/lamgc/cgj/pixiv/PixivUgoiraBuilder.java b/src/main/java/net/lamgc/cgj/pixiv/PixivUgoiraBuilder.java index 5bc321e..73efdb7 100644 --- a/src/main/java/net/lamgc/cgj/pixiv/PixivUgoiraBuilder.java +++ b/src/main/java/net/lamgc/cgj/pixiv/PixivUgoiraBuilder.java @@ -1,5 +1,6 @@ package net.lamgc.cgj.pixiv; +import com.google.common.io.ByteStreams; import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonObject; @@ -12,7 +13,6 @@ import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.util.EntityUtils; -import org.apache.tomcat.util.http.fileupload.util.Streams; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -127,14 +127,13 @@ public final class PixivUgoiraBuilder { HashMap frameMap = new HashMap<>(frames.size()); while((entry = zipInputStream.getNextEntry()) != null) { log.trace("ZipEntry {} 正在接收...", entry); - Streams.copy(zipInputStream, cacheOutputStream, false); + ByteStreams.copy(zipInputStream, cacheOutputStream); frameMap.put(entry.getName(), new ByteArrayInputStream(cacheOutputStream.toByteArray())); log.trace("ZipEntry {} 已接收完成.", entry); cacheOutputStream.reset(); } - - InputStream firstFrameInput = frameMap.get("000000.jpg"); + InputStream firstFrameInput = frameMap.get(frames.get(0).getAsJsonObject().get("file").getAsString()); BufferedImage firstFrame = ImageIO.read(firstFrameInput); firstFrameInput.reset(); if(width != firstFrame.getWidth() || height != firstFrame.getHeight()) {