Hi,
Doing : import AWS from ‘aws-sdk’; works but it adds 7 mb to the JS bundle file.
So we’re trying to import only required modules :
import {Config,CognitoIdentityCredentials, S3} from “aws-sdk”;
But doing that, we don’t understand how to setup credentials so the upload fails because we cannot do this since the AWS object does not exist:
AWS.config.update({
region: client_region,
credentials: new CognitoIdentityCredentials({
IdentityPoolId: POOL_ID })
});
And we get this error when trying to upload:
AttachDocument.jsx:646 attachment: finished uploading to s3 from client err= CredentialsError: Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1
at Request.VALIDATE_REGION (modules.js?hash=d016031ad987ce5ba1a1bb4dcad0c7a4e6755bd6:84335)
at Request.callListeners (modules.js?hash=d016031ad987ce5ba1a1bb4dcad0c7a4e6755bd6:80755)
at Request.emit (modules.js?hash=d016031ad987ce5ba1a1bb4dcad0c7a4e6755bd6:80727)
at Request.emit (modules.js?hash=d016031ad987ce5ba1a1bb4dcad0c7a4e6755bd6:85978)
at Request.transition (modules.js?hash=d016031ad987ce5ba1a1bb4dcad0c7a4e6755bd6:85312)
at AcceptorStateMachine.runTo (modules.js?hash=d016031ad987ce5ba1a1bb4dcad0c7a4e6755bd6:86126)
at Request.runTo (modules.js?hash=d016031ad987ce5ba1a1bb4dcad0c7a4e6755bd6:85698)
at Request.send (modules.js?hash=d016031ad987ce5ba1a1bb4dcad0c7a4e6755bd6:85662)
at features.constructor.makeUnauthenticatedRequest (modules.js?hash=d016031ad987ce5ba1a1bb4dcad0c7a4e6755bd6:81125)
at features.constructor.svc. https://forums.aws.amazon.com/ (modules.js?hash=d016031ad987ce5ba1a1bb4dcad0c7a4e6755bd6:81576) data= undefined
Even if we try to setup the config in the S3 object this way, we get the same error:
let confTmp = new Config({
region: client_region,
apiVersion: “2006-03-01”,
credentials: new CognitoIdentityCredentials({
IdentityPoolId: POOL_ID
})
});
var s3 = new S3(confTmp ) ;
s3.upload(params, function (err, data) {
console.log(“attachment: finished uploading to s3 from client err=”,err, " data=",data);
} );
Any idea what to do ?