[Typescript-Jquery] Fix file upload (#6262)

* Fix a bug with the file upload that was not working

* Prevent unnecessary append to the FormData
This commit is contained in:
Jean-François Côté 2017-08-09 05:05:00 -04:00 committed by wing328
parent e94ba4c36d
commit 00b46e8a94
3 changed files with 5 additions and 15 deletions

View File

@ -103,7 +103,9 @@ export class {{classname}} {
{{#formParams}}
{{#isFile}}
reqHasFile = true;
formParams = {{paramName}};
{{/isFile}}
{{^isFile}}
{{#isListContainer}}
if ({{paramName}}) {
{{#isCollectionFormatMulti}}
@ -121,7 +123,7 @@ export class {{classname}} {
formParams.append('{{baseName}}', <any>{{paramName}});
}
{{/isListContainer}}
{{/isFile}}
{{/formParams}}
{{#headerParams}}
{{#isListContainer}}

View File

@ -433,11 +433,9 @@ export class PetApi {
if (name !== null && name !== undefined) {
formParams.append('name', <any>name);
}
if (status !== null && status !== undefined) {
formParams.append('status', <any>status);
}
// to determine the Content-Type header
let consumes: string[] = [
'application/x-www-form-urlencoded'
@ -515,12 +513,8 @@ export class PetApi {
if (additionalMetadata !== null && additionalMetadata !== undefined) {
formParams.append('additionalMetadata', <any>additionalMetadata);
}
reqHasFile = true;
if (file !== null && file !== undefined) {
formParams.append('file', <any>file);
}
formParams = file;
// to determine the Content-Type header
let consumes: string[] = [
'multipart/form-data'

View File

@ -433,11 +433,9 @@ export class PetApi {
if (name !== null && name !== undefined) {
formParams.append('name', <any>name);
}
if (status !== null && status !== undefined) {
formParams.append('status', <any>status);
}
// to determine the Content-Type header
let consumes: string[] = [
'application/x-www-form-urlencoded'
@ -515,12 +513,8 @@ export class PetApi {
if (additionalMetadata !== null && additionalMetadata !== undefined) {
formParams.append('additionalMetadata', <any>additionalMetadata);
}
reqHasFile = true;
if (file !== null && file !== undefined) {
formParams.append('file', <any>file);
}
formParams = file;
// to determine the Content-Type header
let consumes: string[] = [
'multipart/form-data'