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 "filename" from browser #21

Open
remalkoil opened this issue Jan 8, 2021 · 0 comments
Open

Multipart "filename" from browser #21

remalkoil opened this issue Jan 8, 2021 · 0 comments

Comments

@remalkoil
Copy link

Hello,
I've the following api service's method:

@POST('/my-custom-url')
@Multipart
async uploadFileFromBrowser(@Part('file') file: PartDescriptor<File>): Promise<Response<any>> {
   return {} as Response;
}

I'm calling it (from an Angular project) with the following code:

async uploadAction() {
  const fileInput = document.getElementById('file') as HTMLInputElement;
  const files = fileInput.files;
  const file = files[0];
  const response = await this.api.uploadFileFromBrowser({value: file, filename: file.name});
}

When I call the uploadAction method the "filename field" is the string: "[object Object]" instead of the "textual name of file".

------WebKitFormBoundaryWY9IohJDLcjoMBw7
Content-Disposition: form-data; name="file"; filename="[object Object]"
Content-Type: image/png
[...]

Inside dataResolver.ts, method resolve(headers: any, data: any) the line n. 44 is:
formData.append(key, data[key].value, { filename: data[key].filename });
maybe should be:
formData.append(key, data[key].value, data[key].filename);

Best regards,
Daniele

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

No branches or pull requests

1 participant