user10114552
user10114552

Reputation:

How can I send additional parameters via ng2-file-upload when I upload a file

I have created two selects and want to send their values as parameters to the backend during upload. Do you know how to do that? Can you help me please?

My Code:

// Select Forms
 // Month form
    this.sendMonthsForm = this.fb.group({
      monthsValue: [null]
    });
    // Year form
    this.sendYearsForm = this.fb.group({
      yearsValue: [null]
    });
// Upload
  this.uploader = new FileUploader({
        url: `${environment.baseUrl}/upload?title=SuSa&context=${year}&period=${month}`,
        maxFileSize: 2 * 1024 * 1024,
        allowedFileType: ['csv', 'xls', 'xlsx'],
        authToken: `Bearer ${currentUser.auth_token}`,
      });

Upvotes: 0

Views: 1705

Answers (2)

gowtham
gowtham

Reputation: 1

this.uploader = new FileUploader({
        url: `${environment.baseUrl}/upload?title=SuSa&context=${year}&period=${month}`,
        maxFileSize: 2 * 1024 * 1024,
        additionalParameter:{uploaderparams1:'its-value',uploaderparams2:'its-value'},
        allowedFileType: ['csv', 'xls', 'xlsx'],
        authToken: `Bearer ${currentUser.auth_token}`,
      }); 

Upvotes: 0

Santhosh V
Santhosh V

Reputation: 410

uploader: FileUploader = new FileUploader({
  url: URL,
  headers: [{ name: 'Authorization', value: 'Bearer ejy...' }]
});

Upvotes: 0

Related Questions