Problems with FileUpload component regarding upload to AWS S3

UI Components for Angular
Post Reply
Posts: 1
Joined: 08 Jun 2019, 13:00

08 Jun 2019, 13:04

I'm having an issue with PrimeNG's FileUpload component. I'm using it to upload a file to AWS S3. If I do that through the component itself (by setting the method to PUT and setting the url accordingly), the file is uploaded to S3, but it contains unnecessary data at the beginning of the file. Here's an example of that

Code: Select all

Content-Disposition: form-data; name="myfile[]"; filename="something.png"
Content-Type: image/png
This basically means that the file is 'corrupted' (e.g. an image won't be rendered unless those lines at the beginning are deleted, because otherwise it's an invalid png file). If anyone has an idea about solving this, that'd be great. The rest of the post is my alternative approach to fixing that, so if I can fix this you can ignore the rest.

However, since I didn't manage to find a solution for that, I tried to find a work-around: use a custom uploader to call my own function which makes the PUT request (this way, the file is uploaded as it should be). However, when using a custom uploader, the events aren't being triggered. The only one that I noticed being triggered is onSelect(). I'm assuming that this is why also the progress bar doesn't work when using a custom uploader. My question is basically: how do I get the events to trigger, or at least get the progress bar to work (though I'm assuming those two are related).

Here's a stripped down version of what I'm using. The progress bar still doesn't work (I removed all the callbacks just to make sure I'm not somehow the culprit). Thanks in advance.

Code: Select all

<p-fileUpload #fileInput name="myfile[]" customUpload="true" (uploadHandler)="myUpload($event)">

myUpload(event): void{
    this.some-service.uploadfileAWSS3(this.fileUploadURL, event.files[0]).subscribe(x => {
        // some other stuff here

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 2 guests