Web Connection
File upload to REST Service
Gravatar is a globally recognized avatar based on your email address. File upload to REST Service
  Stein Goering
  All
  Feb 11, 2024 @ 09:28pm

Working on app using the REST API Process class with Vue.js on the front end--need to a way for end users to upload files to the server.

I can use the Vuetify v-file-input control to select the file but am not sure how best to hook into the server side using the REST API. Any advice (or sample code) would be welcome.

--stein

Gravatar is a globally recognized avatar based on your email address. re: File upload to REST Service
  Rick Strahl
  Stein Goering
  Feb 12, 2024 @ 02:42pm

For multipart uploads you need to use multi-part Form variable access.

Set up an endpoint that has no parameters and then manually pull out Request.GetMultipartFormVar() and Request.GetMultipartFiles().

Actually I think you can use Request.Form() to retrieve the simple variables, but for files you'll want to use GetMultipartFiles().

Upload endpoints tend to be specific to uploads so they usually have some sort of reference or context associated with them so you know how to store the files.

There are file upload examples in the Web Connection samples - both plain uploads as well as AJAX uploads (without any special client components).

+++ Rick ---

© 1996-2024