Browse Source

无jira任务 fix: 修改下preserveMetadata配置的效果

release/11.0
Afly 2 months ago
parent
commit
e7ef7f5871
  1. 14
      src/main/java/com/fanruan/fs/s3/repository/core/S3ResourceRepository.java

14
src/main/java/com/fanruan/fs/s3/repository/core/S3ResourceRepository.java

@ -175,15 +175,15 @@ public class S3ResourceRepository extends BaseResourceRepository {
metadata = s3.getObjectMetadata(bucket, path); metadata = s3.getObjectMetadata(bucket, path);
} catch (Exception ignore) { } catch (Exception ignore) {
} }
} if (metadata == null) {
if (metadata == null) { metadata = new ObjectMetadata();
metadata = new ObjectMetadata(); String mimeType = URLConnection.guessContentTypeFromName(path);
String mimeType = URLConnection.guessContentTypeFromName(path); if (mimeType != null) {
if (mimeType != null) { metadata.setContentType(mimeType);
metadata.setContentType(mimeType); }
} }
metadata.setContentLength(length);
} }
metadata.setContentLength(length);
s3.putObject(bucket, path, new ByteArrayInputStream(data), metadata); s3.putObject(bucket, path, new ByteArrayInputStream(data), metadata);
} }
} }

Loading…
Cancel
Save