嗨,
请容忍我,因为我是这方面的新手。
我试图使用将图像文件上传到S3桶,但每次尝试都会收到400个错误。我认为这可能是一个授权问题,因为我在NodeJS中找不到代码中的任何错误。上传后,我将knox客户端对象打印到控制台,并将此部分包含在其中,不确定它是否告诉我AWS没有授权我:
代理人:
Agent { domain: null, \_events: { free: [Function] }, \_eventsCount: 1, \_maxListeners: undefined, defaultPort: 443, protocol: 'https:', options: { path: null }, requests: {}, sockets: { 'photogridjose.s3.amazonaws.com:443:::::::::': [ TLSSocket { \_tlsOptions: { pipe: null, secureContext: SecureContext { context: SecureContext {}, singleUse:真},
isServer: false, requestCert: true, * rejectUnauthorized:真,
_session: undefined,_ _NPNProtocols: undefined,_ _ALPNProtocols: undefined,_ _requestOCSP: undefined },_ _\_secureEstablished: false,_ _\_securePending: false,_ _\_newSessionPending: false,_ _\_controlReleased: true,_ _\_SNICallback: null,_ _servername: null,_ _npnProtocol: null,_ _alpnProtocol: null,_ **authorized: false, \*** authorizationError: null, encrypted: true, \_events: { close: [ [Function], { [Function: bound onceWrapper] listener: [Function] }, [Function: onClose] ], end: [ { [Function: bound onceWrapper] listener: [Function: onend] }, { [Function: bound onceWrapper] listener: [Function: onHangUp] } ], finish: [Function: onSocketFinish], \_socketEnd: [Function: onSocketEnd], secureConnect: { [Function: bound onceWrapper] listener: [Function] }, connect: { [Function: bound onceWrapper] listener: [Function] }, secure: [Function], free: [Function: onFree], agentRemove: [Function: onRemove] }, \_eventsCount: 9, connecting: true, \_hadError: false, \_handle: TLSWrap { bytesRead: 0, \_externalStream: [External], fd: -1, \_parent: TCP { bytesRead: 0, \_externalStream: [External], fd: -1, reading: [Getter/Setter], owner: [Circular], onread: null, onconnection: null, writeQueueSize: 0 }, \_parentWrap: undefined, \_secureContext: SecureContext { context: SecureContext {}, singleUse:真},
reading: false, owner: [Circular], onread: [Function: onread],
我使用了AWS提供的AWSAccessKeyId & AWSSecretKey,并更改了S3桶的策略,因此设置为每个人读/写。
这是我的桶策略医生:
{
"Version": "2012-10-17", "Id": "Policy150032\*\*\*\*\*\*\*", "Statement": [ { "Sid": "Stmt1500\*\*\*\*\*\*\*\*\*", "Effect": "Allow", "Principal": "\*", "Action": [ "s3:GetObject", "s3:PutObject", "\*" ], "Resource": "arn:aws:s3:::Myphotogrid/\*" } ]}
这是我的CORS文档:
<AllowedOrigin>\* </AllowedOrigin> <AllowedMethod>GET </AllowedMethod> <AllowedMethod>POST </AllowedMethod> <AllowedMethod>PUT </AllowedMethod> <AllowedHeader>Authorization </AllowedHeader>下面是该事务的S3桶日志:
配件剥离
访问被拒绝
37329C57F01BEC29
zYNm+4zorTHrNnmHBAYPVpFfkJJ3VL1qtJ+PI9vJPRHhCb7vGhhav4YNRlbbakRJlpyab6Gfcn0=
这里有人有使用AWS S3桶的经验吗?
发布于 2017-07-31 21:47:07
创建了一个新的S3存储桶并删除了旧的存储桶,确保权限对公众来说是正确的读写存储桶,并选择了离我最近的位置的服务器来存储它,这两种方法都解决了我得到的400个错误&然后是307个错误。我现在得到了200个成功的响应,文件被上传到我的S3桶中,没有问题。
https://stackoverflow.com/questions/45422853
复制相似问题