I did check the official AWS SDK documentation and it does support the contentType property.

But after adding the contentType in using the spaces.

    const params = {
      Bucket: 'xxxx',
      Key: path,
      Body: buffer,
      ACL: "public-read",
      contentType: mimetype // data type
    };

And then I get this error.

{ UnexpectedParameter: Unexpected key 'contentType' found in params
    at ParamValidator.fail (/Users/yashumittal/code/centinni/backend/node_modules/aws-sdk/lib/param_validator.js:50:37)
    at ParamValidator.validateStructure (/Users/yashumittal/code/centinni/backend/node_modules/aws-sdk/lib/param_validator.js:77:14)
    at ParamValidator.validateMember (/Users/yashumittal/code/centinni/backend/node_modules/aws-sdk/lib/param_validator.js:88:21)
    at ParamValidator.validate (/Users/yashumittal/code/centinni/backend/node_modules/aws-sdk/lib/param_validator.js:34:10)
    at Request.VALIDATE_PARAMETERS (/Users/yashumittal/code/centinni/backend/node_modules/aws-sdk/lib/event_listeners.js:126:42)
    at Request.callListeners (/Users/yashumittal/code/centinni/backend/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
    at callNextListener (/Users/yashumittal/code/centinni/backend/node_modules/aws-sdk/lib/sequential_executor.js:96:12)
    at /Users/yashumittal/code/centinni/backend/node_modules/aws-sdk/lib/event_listeners.js:86:9
    at finish (/Users/yashumittal/code/centinni/backend/node_modules/aws-sdk/lib/config.js:386:7)
    at /Users/yashumittal/code/centinni/backend/node_modules/aws-sdk/lib/config.js:404:9
    at Credentials.get (/Users/yashumittal/code/centinni/backend/node_modules/aws-sdk/lib/credentials.js:127:7)
    at getAsyncCredentials (/Users/yashumittal/code/centinni/backend/node_modules/aws-sdk/lib/config.js:398:24)
    at Config.getCredentials (/Users/yashumittal/code/centinni/backend/node_modules/aws-sdk/lib/config.js:418:9)
    at Request.VALIDATE_CREDENTIALS (/Users/yashumittal/code/centinni/backend/node_modules/aws-sdk/lib/event_listeners.js:81:26)
    at Request.callListeners (/Users/yashumittal/code/centinni/backend/node_modules/aws-sdk/lib/sequential_executor.js:102:18)
    at Request.emit (/Users/yashumittal/code/centinni/backend/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
  message: 'Unexpected key \'contentType\' found in params',
  code: 'UnexpectedParameter',
  time: 2020-06-30T07:38:10.899Z } 'UnexpectedParameter: Unexpected key \'contentType\' found in params\n    at ParamValidator.fail (/Users/yashumittal/code/centinni/backend/node_modules/aws-sdk/lib/param_validator.js:50:37)\n    at ParamValidator.validateStructure (/Users/yashumittal/code/centinni/backend/node_modules/aws-sdk/lib/param_validator.js:77:14)\n    at ParamValidator.validateMember (/Users/yashumittal/code/centinni/backend/node_modules/aws-sdk/lib/param_validator.js:88:21)\n    at ParamValidator.validate (/Users/yashumittal/code/centinni/backend/node_modules/aws-sdk/lib/param_validator.js:34:10)\n    at Request.VALIDATE_PARAMETERS (/Users/yashumittal/code/centinni/backend/node_modules/aws-sdk/lib/event_listeners.js:126:42)\n    at Request.callListeners (/Users/yashumittal/code/centinni/backend/node_modules/aws-sdk/lib/sequential_executor.js:106:20)\n    at callNextListener (/Users/yashumittal/code/centinni/backend/node_modules/aws-sdk/lib/sequential_executor.js:96:12)\n    at /Users/yashumittal/code/centinni/backend/node_modules/aws-sdk/lib/event_listeners.js:86:9\n    at finish (/Users/yashumittal/code/centinni/backend/node_modules/aws-sdk/lib/config.js:386:7)\n    at /Users/yashumittal/code/centinni/backend/node_modules/aws-sdk/lib/config.js:404:9\n    at Credentials.get (/Users/yashumittal/code/centinni/backend/node_modules/aws-sdk/lib/credentials.js:127:7)\n    at getAsyncCredentials (/Users/yashumittal/code/centinni/backend/node_modules/aws-sdk/lib/config.js:398:24)\n    at Config.getCredentials (/Users/yashumittal/code/centinni/backend/node_modules/aws-sdk/lib/config.js:418:9)\n    at Request.VALIDATE_CREDENTIALS (/Users/yashumittal/code/centinni/backend/node_modules/aws-sdk/lib/event_listeners.js:81:26)\n    at Request.callListeners (/Users/yashumittal/code/centinni/backend/node_modules/aws-sdk/lib/sequential_executor.js:102:18)\n    at Request.emit (/Users/yashumittal/code/centinni/backend/node_modules/aws-sdk/lib/sequential_executor.js:78:10)'
1 comment
  • Alter to:
    ContentType: mimetype // data type

    Example using php:
    ‘ContentType’ => mimecontenttype($_FILES[“file”][“tmp_name”])

Submit an answer

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!