具有InputStream长度示例的AmazonS3 putObject
我正在使用Java将文件上传到S3-到目前为止,这是我得到的: AmazonS3 s3 = new AmazonS3Client(new BasicAWSCredentials("XX","YY")); List<Bucket> buckets = s3.listBuckets(); s3.putObject(new PutObjectRequest(buckets.get(0).getName(), fileName, stream, new ObjectMetadata())); 文件正在上传,但是未设置内容长度时会发出警告: com.amazonaws.services.s3.AmazonS3Client putObject: No content length specified for stream > data. Stream contents will be buffered in memory and could result in out of memory errors. 这是我上传文件和stream变量是InputStream,从中我可以得到字节数组是这样的:IOUtils.toByteArray(stream)。 因此,当我尝试像这样设置内容长度和MD5(从此处获取)时: // get MD5 base64 hash …