|
|
|
@ -28,7 +28,7 @@ import com.fr.workspace.resource.ResourceIOException;
|
|
|
|
|
import java.io.ByteArrayInputStream; |
|
|
|
|
import java.io.InputStream; |
|
|
|
|
import java.net.URL; |
|
|
|
|
import java.nio.charset.Charset; |
|
|
|
|
import java.net.URLConnection; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
@ -163,7 +163,21 @@ public class S3ResourceRepository extends BaseResourceRepository {
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void write(String path, byte[] data) { |
|
|
|
|
s3.putObject(bucket, path, new String(data, Charset.forName(CHAR_SET))); |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
if (metadata != null) { |
|
|
|
|
metadata.setContentLength(data.length); |
|
|
|
|
} |
|
|
|
|
s3.putObject(bucket, path, new ByteArrayInputStream(data), metadata); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|