Turistforeningen / node-s3-uploader

Flexible and efficient resize, rename, and upload images to Amazon S3 disk storage. Uses the official AWS Node SDK for transfer, and ImageMagick for image processing. Support for multiple image versions targets.
https://www.npmjs.com/package/s3-uploader
MIT License
241 stars 54 forks source link

TimeoutError: Missing credentials in config #95

Closed pieterbergmans closed 8 years ago

pieterbergmans commented 8 years ago

Subject of the issue

I'm receiving the following error...TimeoutError: Missing credentials in config.

The code seems to execute but, instead of the files being saved to S3, the files are saved locally. From what I've googled, it may be related to a timing out on S3's end. Could this be and has it happened to any others? Uploading images to S3 via other methods works just fine. The code I'm using is verbatim from the examples posted here on github.

Your environment

Starefossen commented 8 years ago

Hi @pieterbergmans and sorry for the trouble you are having with s3-uploader.

It looks like we managed to remove the S3 authentication documentation from the README.md in the 1.x => 2.0 rewrite. You will need to authenticate with AWS in one of the following ways:

Environment variables:

Constructor options:

new Upload(..., {
  aws: {
    ...,
    secretAccessKey: 'SECRET_ACCESS_KEY_HERE',
    accessKeyId: 'ACCESS_KEY_ID_HERE',
  },
  ...
});
pieterbergmans commented 8 years ago

Hi @Starefossen ...thanks for the quick reply. I am using the second method you mentioned. Here is a console.log() of my config. The S3 access, secret and bucket have been obfuscated.

(Sorry for the bad formatting.)

Upload { opts: { aws: { path: '', accessKeyId: 'AasdfM5K5LDYI2FLAQ', secretKeyId: 'asdfx+asfg1WtIL6lHncF4OlzQAWwh0', region: 'us-west-2', acl: 'public-read', httpOptions: [Object], maxRetries: 3, params: [Object], sslEnabled: true }, cleanup: { versions: true, original: true }, original: { awsImageAcl: 'public-read' }, versions: [ [Object] ], returnExif: false, resize: { quality: 70 }, url: 'https://s3-us-west-2.amazonaws.com/my-s3-bucket/' }, _randomPath: { [Function: v4] v1: [Function: v1], v4: [Circular], parse: [Function: parse], unparse: [Function: unparse], BufferClass: { [Function: Buffer] poolSize: 8192, from: [Function], alloc: [Function], allocUnsafe: [Function], allocUnsafeSlow: [Function], isBuffer: [Function: isBuffer], compare: [Function: compare], isEncoding: [Function], concat: [Function], byteLength: [Function: byteLength] }, _rng: [Function], _mathRNG: undefined, _nodeRNG: [Function], _whatwgRNG: undefined }, s3: Service { config: Config { credentials: null, credentialProvider: [Object], region: 'us-west-2', logger: null, apiVersions: {}, apiVersion: null, endpoint: 's3-us-west-2.amazonaws.com', httpOptions: [Object], maxRetries: 3, maxRedirects: 10, paramValidation: true, sslEnabled: true, s3ForcePathStyle: false, s3BucketEndpoint: false, s3DisableBodySigning: true, computeChecksums: true, convertResponseTypes: true, correctClockSkew: false, customUserAgent: null, dynamoDbCrc32: true, systemClockOffset: 0, signatureVersion: 's3', signatureCache: true, retryDelayOptions: [Object], useAccelerateEndpoint: false, path: '', accessKeyId: 'AasdfM5K5LDYI2FLAQ', secretKeyId: 'asdf9Vx+asdf1SZ46g1WtIL6lHasdflzQAWwh0', acl: 'public-read', params: [Object] }, isGlobalEndpoint: false, endpoint: Endpoint { protocol: 'https:', host: 's3-us-west-2.amazonaws.com', port: 443, hostname: 's3-us-west-2.amazonaws.com', pathname: '/', path: '/', href: 'https://s3-us-west-2.amazonaws.com/' }, _clientId: 1 } }

Starefossen commented 8 years ago

Could you try changing the name of secretKeyId to secretAccessKey, and see if that works better.

pieterbergmans commented 8 years ago

Wow, I feel like such an idiot. I'm not sure where I got secretKeyId from. Thanks for the help!

Starefossen commented 8 years ago

I am always happy to help, and I hope you'll enjoy this library 😄