- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我通过 ajax 请求将文件放入 S3,大约 50% 的时间我会收到 ERR_CONNECTION_RESET 错误。
我知道请求已正确签名 - 有什么想法可能导致此情况吗?同样,这是我从多个位置和机器上看到的间歇性问题。
这是我用来将文件放入 S3 的相关 CoffeeScript 代码。它源自 Micah Roberson 和 Rok Krulec 的工作 http://micahroberson.com/upload-files-directly-to-s3-w-backbone-on-heroku/和 http://codeartists.com/post/36892733572/how-to-directly-upload-files-to-amazon-s3-from-your .
createCORSRequest: (method, url) ->
xhr = new XMLHttpRequest()
if xhr.withCredentials?
xhr.open method, url, true
else if typeof XDomainRequest != "undefined"
xhr = new XDomainRequest()
xhr.open method, url
else
xhr = null
xhr
uploadToS3: (file, signature) ->
this_s3upload = this
this_s3upload.signature = signature
url = signature.signed_request
xhr = @createCORSRequest 'PUT', decodeURIComponent(signature.signed_request)
if !xhr
@onError 'CORS not supported'
else
xhr.onload = () ->
if xhr.status == 200
this_s3upload.onProgress 100, 'Upload completed.'
this_s3upload.onFinishS3Put file, this_s3upload.signature
else
this_s3upload.onError file, 'Upload error: ' + xhr.status
xhr.onerror = () ->
this_s3upload.onError file, 'XHR error.', this_s3upload.signature
xhr.upload.onprogress = (e) ->
if e.lengthComputable
percentLoaded = Math.round (e.loaded / e.total) * 100
if percentLoaded == 100
message = "Finalizing"
else
message = "Uploading"
this_s3upload.onProgress xhr, file, percentLoaded, message, this_s3upload.signature
xhr.onabort = ->
this_s3upload.onAbort file, "XHR cancelled by user.", this_s3upload.signature
xhr.setRequestHeader 'Content-Type', file.type
xhr.setRequestHeader 'x-amz-acl', 'public-read'
xhr.send file
更新
在这个问题上我得到了亚马逊非常周到的支持。根据他们的建议,我创建了一个 EC2 Windows 实例,在其上加载了 Chrome 浏览器,并尝试使用我的代码上传 5 个文件 10 次。我一次都没有看到错误。我偶尔会看到一些 SignatureDoesNotMatch 错误,但没有看到一个 ERR_CONNECTION_RESET 错误。尽管在我使用的每个非 EC2 客户端/网络位置上,我仍然看到 ERR_CONNECTION_RESET 错误。
更新这里仍然没有解决方案。我已经从使用自滚动签名算法转向使用 boto 提供的算法。但对 ERR_CONNECTION_RESET 问题没有影响。
最佳答案
我在使用预签名 URL 上传较大文件(长请求)时遇到了此问题,如下 Heroku's example (节点AWS SDK):
app.get('/sign-s3', (req, res) => {
const s3 = new aws.S3();
const fileName = req.query['file-name'];
const fileType = req.query['file-type'];
const s3Params = {
Bucket: S3_BUCKET,
Key: fileName,
Expires: 60,
ContentType: fileType,
ACL: 'public-read'
};
s3.getSignedUrl('putObject', s3Params, (err, data) => {
if(err){
console.log(err);
return res.end();
}
const returnData = {
signedRequest: data,
url: `https://${S3_BUCKET}.s3.amazonaws.com/${fileName}`
};
res.write(JSON.stringify(returnData));
res.end();
});
});
“Expires”参数使签名 URL 的有效期为 60 秒。
我认为,当签名 URL 在上传过程中过期时,请求会崩溃(即使在上传开始时它是有效的)。
它不会在 60 秒后崩溃,而是在 60 到 120 秒之间随机崩溃。大多数情况下,客户端会记录 ERR_CONNECTION_RESET,有时会记录 403 FORBIDDEN。
将其调至 3600 后,我不再遇到任何问题。
我怀疑 EC2 上没有发生此问题,因为它们的上传速度非常快。
关于ajax - PUTting 到 S3 时出现 ERR_CONNECTION_RESET,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22798774/
我正在处理批处理作业,以通过 HTableInterface 将一批 Put 对象处理到 HBase 中。有两个 API 方法,HTableInterface.put(List) 和 HTableIn
我想转置curl命令(将本地文件上传到机架空间) curl -X PUT -T screenies/hello.jpg -D - \ -H "X-Auth-Token: fc81aaa6-98a1-9
我认为执行 puts #{a} 会产生与 puts a 相同的输出,但发现情况并非如此。考虑: irb(main):001:0> a = [1,2] => [1, 2] irb(main):002:0
我尝试在我的一个移动应用程序中使用这个cordova后台服务插件(我正在使用名为Appery io的基于网络的移动应用程序开发平台)。我已经能够让相当多的 cordova/phonegap 插件正常工
传奇有多个 put。 export function* changeItemsSaga(action) { const prerequisite1 = yield select(prerequ
我正在从工作正常的 jquery $.ajax 切换到使用 AngularJS $http.put 来访问 Restful API。 我可以进行 API 调用,但 PUT 数据未发送 - 因此我的 A
我的 express 里有这个 router.put('/admin/profile?:id/actions', (req, res) => { console.log(req.body.action
我正在浏览 Ruby tutorial , 并了解到代码 puts 'start' puts puts 'end' 会输出三行,但是下面的代码 puts 'start' puts [] puts 'e
我的目标是使用 TreeMap 使 Box 键对象按 Box.volume 属性排序,同时能够将键按 Box.code 区分。在 TreeMap 中不可以吗? 根据下面的测试 1,HashMap pu
我一直在尝试使用HBase客户端库将记录列表插入HBase。 它适用于Table或HTable中的单个Put(不建议使用),但不能识别List(Puts) 错误说:预期:util.List,但是Lis
我正在使用 Google-guava-cache。将其定义为: Cache myCache= CacheBuilder.newBuilder().maximumSize(100).build();
我只是想知道threadContext.put和MDC.put之间的区别。因为,我相信两者都在做相同的操作。 最佳答案 Log4j 2 continues with the idea of the M
我的 GAE 应用程序上有一些模型,并且我已覆盖 put()关于其中一些。当我调用db.put()时有了这些实体的列表,是否可以保证覆盖 put()每个实体都会被调用? 我现在看到的是实体只是被保存而
module Lab def self.foo puts 'foo from lab' end end module M def foo puts 'foo from mo
我正在查看示例 abo3.c来自 Insecure Programming我并没有在下面的例子中摸索类型转换。有人可以启发我吗? int main(int argv,char **argc) {
我正在 symfony2.4 和 angularjs 中构建应用程序。在 Angular 中我创建了资源: app.factory('Tasks', ['$resource', function($r
到处都说[看了很多帖子] PUT 是幂等的,意味着具有相同输入的多个请求将产生与第一个请求相同的结果。 但是,如果我们使用 POST 方法发出具有相同输入的相同请求,那么它又将表现为 PUT。 那么,
这里是WebApiConfig.cs中的路由配置: config.Routes.MapHttpRoute( name: "DefaultApiPut", routeTemplate:
这两种方法有什么区别: getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke( "pressed F10"),
由于匿名 block 和散列 block 看起来大致相同。我正在玩它。我做了一些严肃的观察,如下所示: {}.class #=> Hash 好的,这很酷。空 block 被视为Hash。 print{
我是一名优秀的程序员,十分优秀!