Search code examples
angularjsfile-uploadamazon-s3ng2-file-upload

How to upload images in s3 bucket using angular ng2-file-upload?


Here which code should need to change for upload images on s3 bucket.

uploader: FileUploader = new FileUploader({
    url: URL,
    disableMultipart: true,
    formatDataFunctionIsAsync: true,
    formatDataFunction: async (item) => {
      return new Promise((resolve, reject) => {
        resolve({
          name: item._file.name,
          length: item._file.size,
          contentType: item._file.type,
          date: new Date()
        });
      });
    }
  });

Thanks in advance.


Solution

  • I have implemented in this method.

    ngAfterViewInit() {
      // upload image on aws 
       this.uploader.onAfterAddingFile = (item => {
            // Here S3 image upload code.  
        });
    })