This is a migrated thread and some comments may be shown as answers.

Send file contents (ArrayBuffer) during uploadEventHandler

4 Answers 465 Views
Upload
This is a migrated thread and some comments may be shown as answers.
bjswick33
Top achievements
Rank 1
bjswick33 asked on 28 Jun 2019, 04:15 PM

I might be overlooking something, but I'm looking for a way to send the file itself (rawFile in the FileInfo) with the post. I'm getting all the File information and my additional values in the body, but can't seem to send the contents along with it. We are storing our documents in the DB.

--Angular with Node API.

Thanks for your time!

4 Answers, 1 is accepted

Sort by
0
Accepted
Dimiter Madjarov
Telerik team
answered on 01 Jul 2019, 07:48 AM
Hi Brun,


The described scenario is the default behavior of the Upload component - only the raw file is uploaded to the back-end. You could assure this is the case by inspecting the Network tab of the browsers developer tools. The rest of the FileInfo information is only available in the event handlers of the component.

Regards,
Dimiter Madjarov
Progress Telerik
Get quickly onboarded and successful with your Telerik and Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
bjswick33
Top achievements
Rank 1
answered on 01 Jul 2019, 12:13 PM

Thanks Dimiter for the response! 

I have looked into the network tab and use fiddler to capture the requests/response. I can see the contents of the file in the request, but it looks like it's lost at some point before it hits my api. From there it's no where to be found. Since I can see it on the request I'm going to continue to look into it. I was thinking the whole time it was weird that the upload component would only send over the meta of the file and not the contents itself. If you have any additional input I welcome it, but I'm going to dig into this a little more.

Thanks again.

0
bjswick33
Top achievements
Rank 1
answered on 01 Jul 2019, 03:14 PM

I found it! On my api (using restify) I needed to add options to the restify.plugins.bodyParser. I have added my issue/fix below. With the change the file (buffer) is available in the req.params.  Thanks again with the help!

Old line: server.use(restify.plugins.bodyParser());

New line: server.use(restify.plugins.bodyParser({ mapFiles: true }));

Info from docs: options.mapFiles Boolean? if req.params should be filled with the contents of files sent through a multipart request. formidable is used internally for parsing, and a file is denoted as a multipart part with the filename option set in its Content-Disposition. This will only be performed if mapParams is true. <- I have found this last part to be incorrect unless mapParams is true by default.

0
Dimiter Madjarov
Telerik team
answered on 02 Jul 2019, 07:50 AM
Hello Brun,


Thank you for the update. I am glad the issue is resolved.

Regards,
Dimiter Madjarov
Progress Telerik
Get quickly onboarded and successful with your Telerik and Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Upload
Asked by
bjswick33
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
bjswick33
Top achievements
Rank 1
Share this question
or