- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在尝试将图像文件放入 S3 时遇到一些问题,
exception = "com.amazonaws.SdkClientException";
message = "Unable to calculate MD5 hash: /home/ubuntu/image1517896928.png (No such file or directory)";
我首先在我的服务器上下载 MultipartFile,然后使用我调用 putObject 方法的文件,
因为 S3 putObject 方法采用以下参数 -
putObject(String arg0, String arg1, File arg2)
这是我的代码-
public String uploadImage(MultipartFile image) throws IOException, InterruptedException{
File localFile = new File(SERVER_HOME_DIRECTORY + image.getOriginalFilename());
AmazonS3 s3client = new AmazonS3Client();
s3client.setRegion(Region.getRegion(Regions.EU_CENTRAL_1));
s3client.putObject(new PutObjectRequest("bucketName", "prefix", localFile));
return "ok";
}
最佳答案
我想建议使用TransferManager
,它非常可靠,并且可以为将文件传输到 S3 提供更好的性能。它也是检查上传进度的选项(使用监听器)。
Sample code using TransferManager
TransferManager provides a simple API for uploading content to Amazon S3, and makes extensive use of Amazon S3 multipart uploads to achieve enhanced throughput, performance and reliability.
When possible, TransferManager attempts to use multiple threads to upload multiple parts of a single upload at once. When dealing with large content sizes and high bandwidth, this can have a significant increase on throughput.
关于Java AWS S3 PutObject 多部分文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48699619/
我面临着一个关于 S3 存储桶策略的谜团,它阻止我的 Php S3Client 来自 PutObject。我得到的错误是: Error executing "PutObject" on "https:
我对我的 s3 用户登录拥有完全权限: { "Statement": [ { "Effect": "Allow", "Action": "s3:*",
我想在将图像上传到 S3 后获取文件的链接(或文件名也可以)。我使用以下代码上传并且有效。 s3Bucket.putObject(data, function(err, data){
我按照 http://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_examples.html#iam-policy-example
我编写了以下代码来将文件上传到亚马逊 s3。 var upload = async function() { var uploadURLs = [] for (var i = 0; i {
我在尝试将图像文件放入 S3 时遇到一些问题, exception = "com.amazonaws.SdkClientException"; message = "Unable to ca
我正在像这样将表单直接上传到 aws s3: for (var i = 0; i < imgUploadList.length; i++) { var params = {
当我尝试使用 aws java sdk 将文件上传到 s3 时,收到有关 InvalidRedirectLocation 的错误。 Exception in thread "main" com.ama
下面的代码在本地工作并将文件从目录上传到 S3。它使用 Boto3 和 Python 3。 s3 = boto3.resource('s3', aws_access_key_id=AWS_ACCESS
我们正在使用适用于 Java 的 AWS SDK S3 版本 2.4.2。当我们尝试使用单个连接为多个文件放置对象 (s3.putObject(PutObjectRequest.builder().b
我已经建立了一个 AWS 账户。并且正在尝试将我的第一个程序化 PUT 放入 S3。我已经使用控制台创建了一个桶并将东西放在那里。我还创建了一个子目录 (myFolder) 并将其公开。我创建了 .a
尝试使用 putObject() 函数将 CSV 文件上传到我的 S3 存储桶时,如果文件大于大约 1 MB,它将超时。我能够成功上传的最大 CSV 文件是 1048 KB(25500 行),我尝试上
在保存到 Amazon S3 时大约有一次\每周文件上传失败 (1\300)。以下代码运行良好,足以确认文件已正确保存,但我忍不住认为还有更好的方法。当文件确实失败时,不会抛出任何异常,所以我永远无法
我正在使用以下代码将文件放入 S3 存储中。我发现它非常慢。秒表指示 18 秒+。有什么建议或其他经验吗? // upload the file to S3 Amazo
我正在尝试将图像上传到 S3,但是当我调用 s3.putObject(params, callback) 时,我的回调永远不会被调用,也不会记录任何错误。 以下是相关代码: var params =
我的目标是允许一个用户将对象放入 s3 存储桶中。我想过应用存储桶策略。我知道您不能拒绝所有用户的 PutObjects,然后通过对所需用户的允许来覆盖它。我曾希望使用条件“ArnNotEquals”
我正在使用独立的 PHP-S3 类: http://undesigned.org.za/2007/10/22/amazon-s3-php-class 我已经尝试了所有现成的教程,下载了源码,更改了相应
你知道方法吗 - public PutObjectResult putObject(PutObjectRequest putObjectRequest) 在 AmazonS3Client 中阻塞? 最
我需要在使用 putObject() 时模拟 AWS S3。 调用该函数时,我需要创建具有用户元数据值的文件。我试图在网上找到一些代码示例,但我只找到了这个基本代码: var AWSMock = re
使用适用于 Javascript 的 aws-sdk 我遇到了一个奇怪的问题,即在将文本放入对象后,特殊字符没有被翻译 这是我的代码: var AWS = require('aws-sdk'); AW
我是一名优秀的程序员,十分优秀!