压缩后将文件上载到s3

uz75evzq  于 2021-08-25  发布在  Java
关注(0)|答案(0)|浏览(234)

我正在使用springboot和AWSAPI开发s3的上传功能,但我无法压缩文件。
下面是代码,请告诉我如何压缩我的代码

public ApiResponse<?> uploadFile(MultipartFile file) throws Exception {
        logger.info("------------Start:: UploadFileService :uploadFileToS3-----------------");
        String fileName = file.getOriginalFilename();
        FileUploadEntity fileUploadEntityResult = null;
        ByteArrayInputStream inputStream = new ByteArrayInputStream(file.getBytes());
        if (StringUtils.isNotEmpty(fileName) && ObjectUtils.isNotEmpty(inputStream)) {
            ObjectMetadata objectMetadata = new ObjectMetadata();
            objectMetadata.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION);
            PutObjectRequest putRequest = new PutObjectRequest("kads-property-documents", fileName, inputStream, objectMetadata)
                    .withCannedAcl(CannedAccessControlList.PublicRead);
            try {
                PutObjectResult putObjectResult = amazonS3EncryptionV2.putObject(putRequest);

}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题