Solución:
Finalmente llegué con la solución después de pasar un par de horas en ella. Los pasos de las soluciones son los siguientes para Angular 8 Project.
-
Instalar dependencia
npm install –save-dev @ types / node
-
Necesita agregar “tipos”: [“node”] al tsconfig.app.json
-
Agregue las siguientes líneas en polyfills.js
if (typeof (window as any).global === 'undefined') { (window as any).global = window; }
Referencia: Última respuesta de @AWS PS (Paso 1)
Referencia: https://github.com/aws/aws-sdk-js/issues/1271 (paso 2)
Referencia: https://github.com/bevacqua/dragula/issues/602 (Paso 3)
Finalmente, resolví el problema mediante los siguientes pasos:
Paso 1 :
npm install –save-dev @ types / node
Paso 2 :
Utilice la referencia: https://github.com/aws/aws-sdk-js/issues/1271 (paso 2)
Paso 3 :
Utilice la referencia: https://github.com/bevacqua/dragula/issues/602 (paso 3)
public uploadFileToAws(file, folderName, newFileName) {
var aws_cognito_identity_pool_id = environment.pool_id;
var aws_cognito_region = environment.aws_cognito_region;
var aws_project_region = environment.aws_project_region;
AWS.config.region = aws_project_region;
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: aws_cognito_identity_pool_id
}, {
region: aws_cognito_region
});
AWS.config.update({ customUserAgent: 'MobileHub v0.1' });
const s3 = new S3({
apiVersion: '2006-03-01',
params: { Bucket: environment.bucket }
});
s3.upload({
Key: folderName+"https://foroayuda.es/"+newFileName,
Bucket: environment.bucket,
Body: file,
ACL: 'private'
},function (err, data) {
this.fileuploading = false;
if (err) {
console.log(err, 'there was an error uploading your file');
} else {
console.log(data.Key+ ' uploaded successfully');
}
return true;
});
}