|
@@ -45,10 +45,15 @@ public class S3FileService extends AbstractFYunFileService {
|
|
|
|
|
|
@Override
|
|
|
public void uploadFile(String bucket, String filePath, String remoteFilePath) throws Exception {
|
|
|
- uploadFile(bucket, filePath, remoteFilePath,true);
|
|
|
+ uploadFile(bucket, filePath, remoteFilePath,true,null);
|
|
|
}
|
|
|
|
|
|
- private void uploadFile(String bucket, String filePath, String remoteFilePath, Boolean shutdown) throws Exception {
|
|
|
+ @Override
|
|
|
+ public void uploadFile(String bucket, String filePath, String remoteFilePath, Map<String, String> headers) throws Exception {
|
|
|
+ uploadFile(bucket, filePath, remoteFilePath,true,headers);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void uploadFile(String bucket, String filePath, String remoteFilePath, Boolean shutdown,Map<String, String> headers) throws Exception {
|
|
|
try {
|
|
|
File file = new File(filePath);
|
|
|
if (!file.exists()) {
|
|
@@ -64,6 +69,11 @@ public class S3FileService extends AbstractFYunFileService {
|
|
|
if (filePath.contains(".png")) {
|
|
|
metadata.setContentType("image/png");
|
|
|
}
|
|
|
+ if(org.apache.commons.lang3.ObjectUtils.isNotEmpty(headers)){
|
|
|
+ for (Map.Entry<String, String> header : headers.entrySet()) {
|
|
|
+ metadata.setHeader(header.getKey(),header.getValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
PutObjectRequest request = new PutObjectRequest(bucket, remoteFilePath, file);
|
|
|
request.withCannedAcl(CannedAccessControlList.PublicRead);
|
|
|
request.withMetadata(metadata);
|
|
@@ -149,7 +159,7 @@ public class S3FileService extends AbstractFYunFileService {
|
|
|
public void uploadMulFiles(String bucket, Map<String, String> filepaths) throws Exception {
|
|
|
try {
|
|
|
for (Map.Entry<String, String> entry : filepaths.entrySet()) {
|
|
|
- uploadFile(bucket, entry.getKey(), entry.getValue(), false);
|
|
|
+ uploadFile(bucket, entry.getKey(), entry.getValue(), false,null);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
log.error("OSS批量上传文件失败!");
|