From 42110ac049ad288d131e850ac4402c7413a5fb43 Mon Sep 17 00:00:00 2001 From: "Seth.Tian" Date: Mon, 15 Mar 2021 10:40:05 +0800 Subject: [PATCH] =?UTF-8?q?QFX-5192=20update:=E6=9B=B4=E6=96=B0=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=8F=B7,=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=B8=AAkey?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E4=BD=86=E6=98=AFlength=E4=B8=8D=E4=B8=80?= =?UTF-8?q?=E6=A0=B7=E6=97=B6=E4=BC=9A=E5=AF=BC=E8=87=B4=E5=86=99=E5=85=A5?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin.xml | 2 +- .../s3/repository/core/S3ResourceRepository.java | 16 +++------------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/plugin.xml b/plugin.xml index 340a630..d89f9df 100644 --- a/plugin.xml +++ b/plugin.xml @@ -5,7 +5,7 @@ com.fanruan.fs yes no - 2.0 + 2.2 10.0 2020-01-27 richie diff --git a/src/main/java/com/fanruan/fs/s3/repository/core/S3ResourceRepository.java b/src/main/java/com/fanruan/fs/s3/repository/core/S3ResourceRepository.java index 540d27c..49bd4e6 100644 --- a/src/main/java/com/fanruan/fs/s3/repository/core/S3ResourceRepository.java +++ b/src/main/java/com/fanruan/fs/s3/repository/core/S3ResourceRepository.java @@ -28,7 +28,7 @@ import com.fr.workspace.resource.ResourceIOException; import java.io.ByteArrayInputStream; import java.io.InputStream; import java.net.URL; -import java.net.URLConnection; +import java.nio.charset.Charset; import java.util.ArrayList; import java.util.List; @@ -40,6 +40,7 @@ import java.util.List; public class S3ResourceRepository extends BaseResourceRepository { private static final String DELIMITER = "/"; + private static final String CHAR_SET = "UTF-8"; private final AmazonS3 s3; private final String bucket; @@ -162,18 +163,7 @@ public class S3ResourceRepository extends BaseResourceRepository { @Override public void write(String path, byte[] data) { - ObjectMetadata metadata; - try { - metadata = s3.getObjectMetadata(bucket, path); - } catch (Exception e) { - metadata = new ObjectMetadata(); - String mimeType = URLConnection.guessContentTypeFromName(path); - if (mimeType != null) { - metadata.setContentType(mimeType); - } - metadata.setContentLength(data.length); - } - s3.putObject(bucket, path, new ByteArrayInputStream(data), metadata); + s3.putObject(bucket, path, new String(data, Charset.forName(CHAR_SET))); }