amazon-web-services - 当用户尝试使用 AWS 注册和创建新账户/相册时,我们收到错误消息。请参阅下面的终端消息

标签 amazon-web-services amazon-s3 bucket

[AWS s3 undefined 0.006s 0 retries] headObject({ Bucket: 'mypicturebank', Key: 'testing' })
创建相册时出错:TypeError [ERR_INVALID_ARG_TYPE]:“key”参数必须是 string、TypedArray 或 DataView 类型之一。接收类型未定义

最佳答案

@Ken G我不确定您使用的是哪种语言或框架,但我遇到了类似的错误消息 The "key" argument must be one of type string, TypedArray, or DataView. Received type undefined现在。

就我而言,对于其他任何偶然发现此问题的人来说,这是因为我提供了 PascalCase从 AWS 返回的 AWS 凭证 STS.assumeRole , 我需要提供的地方 camelCase AWS 凭证 key :

import AWS from 'aws-sdk'

# Bad
const s3 = new AWS.S3({
  credentials: {
    AccessKeyId: process.env.AWS_ACCESS_KEY,
    SecretAccessKey: process.env.AWS_SECRET_KEY,
  },
  ...
})

# Good
const s3 = new AWS.S3({
  credentials: {
    accessKeyId: process.env.AWS_ACCESS_KEY,
    secretAccessKey: process.env.AWS_SECRET_KEY,
  },
  ...
})

我正在使用 aws-sdk for JavaScript在带有 Node v10.16.2 的 macOS 上,目标是使用 s3.createPresignedPost .

可能相关,在运行节点 10.x 的 AWS Lambda 实例上,我看到相同代码的不同错误消息:Key must be a buffer .

关于amazon-web-services - 当用户尝试使用 AWS 注册和创建新账户/相册时,我们收到错误消息。请参阅下面的终端消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50401452/

相关文章:

ruby-on-rails - Seahorse::Client::NetworkingError 使用 rails 上传 Amazon S3 文件

amazon-web-services - CloudFormation S3 指定物理名称

python - 使用 Python lambda 中的 JSON 日志格式

amazon-web-services - 限制AWS EC2实例仅访问同一区域中的S3存储桶

amazon-web-services - Fn :GetAtt Not returning StateMachine. 名称为字符串

amazon-web-services - 如何每次从s3下载新上传的文件到ec2

amazon-web-services - 在路径样式弃用后,存储桶名称中仍允许使用句点 (.)

google-cloud-platform - 为 Google Cloud Storage 中存储桶中的所有对象设置元数据

python - AWS 上的 Streamlit : serverless options?

java - 动态模块 : does delete count against read or write capacity?