mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-08 12:39:05 +08:00
Revert "refactor(common-oss): S3文件上传简化去掉byteinputstream"
This reverts commit a7f85b5824de208f5b692cf62a8f7caa16fea4ea.
This commit is contained in:
1 parent
7a97f94557
commit
3e016ecc4f
1 file changed
+10
-2
+10
-2
@@ -28,6 +28,7 @@ import com.amazonaws.client.builder.AwsClientBuilder;
|
||||
import com.amazonaws.services.s3.AmazonS3;
|
||||
import com.amazonaws.services.s3.AmazonS3Client;
|
||||
import com.amazonaws.services.s3.model.*;
|
||||
import com.amazonaws.util.IOUtils;
|
||||
import com.pig4cloud.pigx.common.file.core.FileProperties;
|
||||
import com.pig4cloud.pigx.common.file.core.FileTemplate;
|
||||
import lombok.Cleanup;
|
||||
@@ -35,6 +36,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
@@ -210,15 +212,21 @@ public class OssTemplate implements InitializingBean, FileTemplate {
|
||||
* @param stream 文件流
|
||||
* @param size 大小
|
||||
* @param contextType 类型
|
||||
* @throws Exception
|
||||
* @see <a href="http://docs.aws.amazon.com/goto/WebAPI/s3-2006-03-01/PutObject">AWS
|
||||
* API Documentation</a>
|
||||
*/
|
||||
public PutObjectResult putObject(String bucketName, String objectName, InputStream stream, long size,
|
||||
String contextType) {
|
||||
String contextType) throws Exception {
|
||||
// String fileName = getFileName(objectName);
|
||||
byte[] bytes = IOUtils.toByteArray(stream);
|
||||
ObjectMetadata objectMetadata = new ObjectMetadata();
|
||||
objectMetadata.setContentLength(size);
|
||||
objectMetadata.setContentType(contextType);
|
||||
return amazonS3.putObject(bucketName, objectName, stream, objectMetadata);
|
||||
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes);
|
||||
// 上传
|
||||
return amazonS3.putObject(bucketName, objectName, byteArrayInputStream, objectMetadata);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user