gpt4 book ai didi

node.js - Node : Uploading plain text to s3 via Knox and I get statusCode = 505?

转载 作者:搜寻专家 更新时间:2023-10-31 22:36:57 26 4
gpt4 key购买 nike

我有以下代码,其中 message 是一个 JSON 字符串。我正在尝试将消息的 md5 作为目标文件名上传到 s3。我收到“505”状态码。我是 NodeJS 的新手,不确定我做错了什么?

knoxInitParams =
'key': awsKey
'secret': awsPrivateKey
'bucket': bucket

client = knox.createClient knoxInitParams

buff = new Buffer message
reqHeader =
'Content-Length': buff.length
'Content-Type': 'text/plain'
'x-amz-acl': 'private'

req = client.put '/tmp/xxx.txt', reqHeader
req.on 'response', (res) ->
console.log res.statusCode
console.log res.headers
if res.statusCode is 200
console.log res.url
req.on 'error', (err) ->
console.error "S3 Error: ", err
req.end buff

编辑:将目的地更改为对其进行硬编码,因为下面的回复指出这是导致问题的原因。但是,我现在收到 403 :(

最佳答案

您的代码看起来不错。

确保您的日期/时间正确。 ntpdate -s pool.ntp.org

关于node.js - Node : Uploading plain text to s3 via Knox and I get statusCode = 505?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10276214/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com