Adds some Fixes for AWS Support.
AWS Requires any additional parameters to be specified BEFORE Files.
This also adds the ability to specify a {{file_name}} template in any
additional parameters to allow adding the filename to additional
parameters.
For example, you can now specify:
additionalParameter: {
key: "path/to/uploads/{{file_name}}"
}
This commit is contained in:
@@ -307,13 +307,20 @@ export class FileUploader {
|
||||
sendable = new FormData();
|
||||
this._onBuildItemForm(item, sendable);
|
||||
|
||||
sendable.append(item.alias, item._file, item.file.name);
|
||||
|
||||
// For AWS, Additional Parameters must come BEFORE Files
|
||||
if (this.options.additionalParameter !== undefined) {
|
||||
Object.keys(this.options.additionalParameter).forEach((key:string) => {
|
||||
sendable.append(key, this.options.additionalParameter[key]);
|
||||
let paramVal = this.options.additionalParameter[key];
|
||||
// Allow an additional parameter to include the filename
|
||||
if (paramVal.indexOf('{{file_name}}') >= 0) {
|
||||
paramVal.replace('{{file_name}}', item.file.name);
|
||||
}
|
||||
sendable.append(key, paramVal);
|
||||
});
|
||||
}
|
||||
|
||||
sendable.append(item.alias, item._file, item.file.name);
|
||||
} else {
|
||||
sendable = item._file;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user