I'm replacing s3cmd
usage with AWS JS SDK.
In s3cmd
command there is an option to set a custom config file: s3cmd -c "/path/to/config"
. But I can't find how to use the same configuration file in "aws-sdk" (shared credentials file)?
My code looks like following:
let cnf_file = path.join(__dirname, "../config");
process.env.AWS_SHARED_CREDENTIALS_FILE = cnf_file;
const S3 = require('aws-sdk/clients/s3');
let s3 = new S3();
let params = {
//...
};
s3.putObject(params, (err, response) => {});
But I get errors:
message: 'Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1',
message: 'Could not load credentials from any providers',