|
|
|
@ -15,12 +15,14 @@ import com.amazonaws.services.s3.model.ObjectMetadata;
|
|
|
|
|
import com.amazonaws.services.s3.model.PutObjectRequest; |
|
|
|
|
import com.amazonaws.services.s3.model.S3Object; |
|
|
|
|
import com.amazonaws.services.s3.model.S3ObjectSummary; |
|
|
|
|
import com.amazonaws.util.IOUtils; |
|
|
|
|
import com.fanruan.api.log.LogKit; |
|
|
|
|
import com.fanruan.api.util.StringKit; |
|
|
|
|
import com.fr.io.repository.FineFileEntry; |
|
|
|
|
import com.fr.io.repository.base.BaseResourceRepository; |
|
|
|
|
import com.fr.stable.Filter; |
|
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
import com.fr.third.org.apache.commons.io.output.NullOutputStream; |
|
|
|
|
import com.fr.workspace.resource.ResourceIOException; |
|
|
|
|
|
|
|
|
|
import java.io.ByteArrayInputStream; |
|
|
|
@ -57,6 +59,8 @@ public class S3ResourceRepository extends BaseResourceRepository {
|
|
|
|
|
amazonS3ClientBuilder = amazonS3ClientBuilder.enablePathStyleAccess(); |
|
|
|
|
} |
|
|
|
|
ClientConfiguration clientConfiguration = new ClientConfiguration(); |
|
|
|
|
clientConfiguration.setMaxConnections(config.getMaxConnections()); |
|
|
|
|
LogKit.info("Max connections is {}!", clientConfiguration.getMaxConnections()); |
|
|
|
|
if (StringUtils.isNotEmpty(config.getSignerOverride())) { |
|
|
|
|
clientConfiguration.setSignerOverride(config.getSignerOverride()); |
|
|
|
|
} |
|
|
|
@ -128,6 +132,8 @@ public class S3ResourceRepository extends BaseResourceRepository {
|
|
|
|
|
try { |
|
|
|
|
return s3.getObject(request).getObjectContent(); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
LogKit.error("[S3] Failed to read file {}", filePath); |
|
|
|
|
LogKit.error(e.getMessage(), e); |
|
|
|
|
return new ByteArrayInputStream(new byte[0]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -341,6 +347,8 @@ public class S3ResourceRepository extends BaseResourceRepository {
|
|
|
|
|
S3Object s3Object = s3.getObject(bucket, path); |
|
|
|
|
if (s3Object != null) { |
|
|
|
|
try { |
|
|
|
|
//s3Object要全部读完,否则会有警告
|
|
|
|
|
IOUtils.copy(s3Object.getObjectContent(), new NullOutputStream()); |
|
|
|
|
return s3Object.getObjectMetadata().getLastModified().getTime(); |
|
|
|
|
} finally { |
|
|
|
|
s3Object.close(); |
|
|
|
|