/** * S3上ファイルのContentTypeチェック * * @param filePath * @return */ public static String getContentType(String filePath) { String contenType = null; try { ClientConfiguration configuration = new ClientConfiguration(); AmazonS3 s3 = new AmazonS3Client(awsContext.getAwsCredentials(), configuration); S3Object object = s3.getObject(YOUR_BACKET, filePath); if (object == null) { throw new Exception("S3 object is null : path = " + filePath); } if (object != null && object.getObjectMetadata() != null && object.getObjectMetadata().getContentType() != null) { contenType = object.getObjectMetadata().getContentType(); } } catch (AmazonServiceException ase) { throw new Exception(ase); } catch (AmazonClientException ace) { throw new Exception(ace); } return contenType; }