Skip to content

Commit 003f1eb

Browse files
authored
Merge pull request #403 from serhiisol/set-forms-name
Fix #22: Unable to set form's "name" on file upload
2 parents b501163 + b886f78 commit 003f1eb

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Follow me [![twitter](https://img.shields.io/twitter/follow/valorkin.svg?style=s
4242
1. `url` - URL of File Uploader's route
4343
2. `authToken` - Auth token that will be applied as 'Authorization' header during file send.
4444
3. `disableMultipart` - If 'true', disable using a multipart form for file upload and instead stream the file. Some APIs (e.g. Amazon S3) may expect the file to be streamed rather than sent via a form. Defaults to false.
45+
4. `itemAlias` - item alias (form name redefenition)
4546

4647
### Events
4748

components/file-upload/file-item.class.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { FileUploader, ParsedResponseHeaders, FileUploaderOptions } from './file
44
export class FileItem {
55
public file:FileLikeObject;
66
public _file:File;
7-
public alias:string = 'file';
7+
public alias:string;
88
public url:string = '/';
9-
public method:string = 'POST';
9+
public method:string;
1010
public headers:any = [];
1111
public withCredentials:boolean = true;
1212
public formData:any = [];
@@ -31,8 +31,9 @@ export class FileItem {
3131
this.options = options;
3232
this.file = new FileLikeObject(some);
3333
this._file = some;
34-
if (uploader.options && uploader.options.method) {
35-
this.method = uploader.options.method;
34+
if (uploader.options) {
35+
this.method = uploader.options.method || 'POST';
36+
this.alias = uploader.options.itemAlias || 'file';
3637
}
3738
this.url = uploader.options.url;
3839
}

components/file-upload/file-uploader.class.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export interface FileUploaderOptions {
2929
removeAfterUpload?:boolean;
3030
url?:string;
3131
disableMultipart?:boolean;
32+
itemAlias?: string;
3233
}
3334

3435
export class FileUploader {

0 commit comments

Comments
 (0)