编程语言
首页 > 编程语言> > javascript – 在Node.js AWS SDK中配置区域

javascript – 在Node.js AWS SDK中配置区域

作者:互联网

有人可以解释如何使用Node.js修复丢失的配置错误吗?我已经按照aws doc page中的所有示例进行了操作,但无论如何我仍然会收到此错误.

{ [ConfigError: Missing region in config]
message: 'Missing region in config',
code: 'ConfigError',
time: Wed Jun 24 2015 21:39:58 GMT-0400 (EDT) }>{ thumbnail: 
 { fieldname: 'thumbnail',
 originalname: 'testDoc.pdf',
 name: 'testDoc.pdf',
 encoding: '7bit',
 mimetype: 'application/pdf',
path: 'uploads/testDoc.pdf',
 extension: 'pdf',
 size: 24,
 truncated: false,
 buffer: null } }
 POST / 200 81.530 ms - -

这是我的代码:

var express = require('express');
var router = express.Router();
var AWS = require('aws-sdk');
var dd = new AWS.DynamoDB();
var s3 = new AWS.S3();
var bucketName = 'my-bucket';

AWS.config.update({region:'us-east-1'});

(...)

解决方法:

如何改变陈述的顺序?
在实例化s3和dd之前更新AWS配置

var AWS = require('aws-sdk');
AWS.config.update({region:'us-east-1'});

var dd = new AWS.DynamoDB();
var s3 = new AWS.S3();

标签:javascript,node-js,amazon-web-services,aws-sdk
来源: https://codeday.me/bug/20190930/1835753.html