awss3
import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.HashMap; import java.util.Map; import javax.imageio.ImageIO; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.PropertySource; import org.springframework.stereotype.Component; import com.amazonaws.ClientConfiguration; import com.amazonaws.Protocol; import com.amazonaws.auth.AWSCredentials; import com.amazonaws.auth.AWSStaticCredentialsProvider; import com.amazonaws.auth.BasicAWSCredentials; import com.amazonaws.regions.Region; import com.amazonaws.regions.Regions; import com.amazonaws.services.s3.AmazonS3; import com.amazonaws.services.s3.AmazonS3Client; import com.amazonaws.services.s3.AmazonS3ClientBuilder; import com.amazonaws.services.s3.model.AccessControlList; import com.amazonaws.services.s3.model.GroupGrantee; import com.amazonaws.services.s3.model.Permission; import com.amazonaws.services.s3.model.S3Object; import org.springframework.web.multipart.MultipartFile; /** * S3 接続取得. * * @param なし * @return s3Client */ @SuppressWarnings("deprecation") public AmazonS3Client getS3ClientConnection() { // // // 証書. // AWSCredentials credentials = new BasicAWSCredentials(s3Accesskey, s3Secretkey); // AmazonS3Client amazonS3Client = new AmazonS3Client(credentials); // // S3所属地域 // Region region = Region.getRegion(Regions.AP_NORTHEAST_1);// Regions.US_EAST_1 // amazonS3Client.setRegion(region); BasicAWSCredentials creds = new BasicAWSCredentials(s3Accesskey, s3Secretkey); ClientConfiguration config = new ClientConfiguration(); config.setProtocol(Protocol.HTTPS); config.setProxyHost("172.16.200.15"); config.setProxyPort(80); AmazonS3Client amazonS3Client = (AmazonS3Client) AmazonS3ClientBuilder.standard() .withClientConfiguration(config) .withRegion(Regions.AP_NORTHEAST_1) .withCredentials(new AWSStaticCredentialsProvider(creds)) .build(); //AmazonS3Client amazonS3Client = (AmazonS3Client)(AmazonS3ClientBuilder.standard().build()); return amazonS3Client; }