Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multipart/formdata file handling is not working correctly due FormData.append issue #205

Open
dmushkov opened this issue Aug 29, 2019 · 1 comment

Comments

@dmushkov
Copy link

dmushkov commented Aug 29, 2019

There is a problem with generated code in case of using Multipart/Formdata
There is a need generated code to be in form
updateUsingPOSTResponse(params: DefinitionMetadataResourceService.UpdateDefinitionUsingPOSTParams): __Observable<__StrictHttpResponse<Array<MetadataDTO>>> { let __params = this.newParams(); let __headers = new HttpHeaders(); let __body: any = null; __headers.append('Content-Type', 'multipart/form-data'); let __formData = new FormData(); __body = __formData; if(params.definitionId !== null && typeof params.definitionId !== "undefined") { __formData.append('definitionId', params.definitionId as string | Blob);} if(params.tableResources !== null && typeof params.tableResources !== "undefined") { __formData.append('tableResources', params.tableResources as string | Blob, this is missing -> params.name);} if(params.fileResources !== null && typeof params.fileResources !== "undefined") { __formData.append('fileResources', params.fileResources as string | Blob, this is missing -> params.name);} let req = new HttpRequest<any>( 'POST', this.rootUrl + /api/definitions/update, __body, { headers: __headers, params: __params, responseType: 'json' }); return this.http.request<any>(req).pipe( __filter(_r => _r instanceof HttpResponse), __map((_r) => { return _r as __StrictHttpResponse<Array<MetadataDTO>>; }) ); }

so basically we need 3rd param to formdata.append in order code to work in IE

more about issue
https://developer.mozilla.org/en-US/docs/Web/API/FormData/append
section for IE notes
With the "Include local directory pass when uploading files to a server" option enabled, IE will change the filename inside the Blob on the fly. To have direct control of the sent filename, the developer should send the filename as the third parameter value, i.e. formData.append(name, value, filename).

@luisfpg
Copy link
Collaborator

luisfpg commented Mar 12, 2020

Which version of IE fails?
According to http://researchhubs.com/post/computing/javascript/upload-files-with-ajax.html IE10 should work with all FormData methods.
And the only supported version of IE is 11, so, it shouldn't be needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants