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))); }