Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to upload file in AWS S3 from Angular 8

I am facing errors while uploading files to S3 from Angular 8 Project. I have follow below tutorial and do the required things

https://medium.com/ramsatt/angular-7-upload-file-to-amazon-s3-bucket-ba27022bad54

But I am not able to use S3 Library in service file.

Error Screenshot

below lines are generating errors that i think but still not sure where is missing things

import * as AWS from 'aws-sdk/global';

import * as S3 from 'aws-sdk/clients/s3';

Is there anyone who can help me to get rid out of it.

like image 768
Rushabh Madhu Avatar asked Jan 02 '20 14:01

Rushabh Madhu


1 Answers

I finally come with solution after spending couple of hours on it. solutions steps are as below for Angular 8 Project.

  1. Install dependancy

    npm install --save-dev @types/node

  2. Need to add "types": ["node"] to the tsconfig.app.json

  3. Add below lines in polyfills.js

    if (typeof (window as any).global === 'undefined') { (window as any).global = window; }
    

Reference : Last answer by @AWS PS (Step 1)
Reference : https://github.com/aws/aws-sdk-js/issues/1271 (Step 2)
Reference : https://github.com/bevacqua/dragula/issues/602 (Step 3)

like image 193
Rushabh Madhu Avatar answered Oct 02 '22 14:10

Rushabh Madhu