multipartform-data

How to post form-data IFormFile with HttpClient?

南笙酒味 提交于 2020-05-14 18:42:06
问题 I have backend endpoint Task<ActionResult> Post(IFormFile csvFile) and I need to call this endpoint from HttpClient. Currently I am getting Unsupported media type error . Here is my code: var filePath = Path.Combine("IntegrationTests", "file.csv"); var gg = File.ReadAllBytes(filePath); var byteArrayContent = new ByteArrayContent(gg); var postResponse = await _client.PostAsync("offers", new MultipartFormDataContent { {byteArrayContent } }); 回答1: You need to specify parameter name in

Multipart form data post method using express js

两盒软妹~` 提交于 2020-05-14 11:59:30
问题 I tried to post form data to my express js server side. This is my pug file form(action="/profile" method="post" enctype="multipart/form-data") input(type="file" accept="image/*" name="profileimage") input(type="text" name="username") input(type="submit" value="Upload") After that I tried to log the post data with req.body inside server side js as follow. That is my profile.js router.post('/', function (req, res) { console.log('Body- ' + JSON.stringify(req.body)); }); And this is my console

Multipart form data post method using express js

佐手、 提交于 2020-05-14 11:57:08
问题 I tried to post form data to my express js server side. This is my pug file form(action="/profile" method="post" enctype="multipart/form-data") input(type="file" accept="image/*" name="profileimage") input(type="text" name="username") input(type="submit" value="Upload") After that I tried to log the post data with req.body inside server side js as follow. That is my profile.js router.post('/', function (req, res) { console.log('Body- ' + JSON.stringify(req.body)); }); And this is my console

Swagger send body and formData parameter [duplicate]

丶灬走出姿态 提交于 2020-05-12 11:14:45
问题 This question already has answers here : In Swagger, how to define an API that consumes a file along with a schema parameter? (3 answers) Closed last month . I'm using Swagger 2.0 and I have a problem to send multiple post parameters. I have a swagger error Operation cannot have a body parameter and a formData parameter and I don't know how to fix it. In my definition I have a body parameter and this parameter need a JSON format but a side I have other parameter like files to upload and

JavaScript - create a file out of json object and use it in a FormData

我只是一个虾纸丫 提交于 2020-04-18 06:26:09
问题 I'm trying to simulate a file upload by providing file content instead of serving the real file. So - I'm doing something like this: uploadFile(jsonContent: string, otherParams: string) { const formData = new FormData(); formData.append('jsonContent', data, 'fileName.json'); formData.append('deal_id', dealId); return this.http.post(this.base_url + '/files', formData);} I'm not seeing the content being sent to the API. Any advice? What I'm doing wrong? 回答1: Well, I've found a solution for this

How to upload multiple images to the Rest API in Flutter using HTTP?

无人久伴 提交于 2020-04-17 21:12:26
问题 I want to upload multiple images into the Rest API. I tried the below code to upload a single image to the rest API. That is working fine , for multiple image selection I'm using multi_image_picker link, how can I modified below code to upload multiple images? Thank you Future<String> uploadSingleImage(File file,String userid) async { final prefs = await SharedPreferences.getInstance(); final key = 'token'; final value = prefs.get(key ) ?? 0; String fileName = file.path.split("/").last; var

How to pass multipart request from one server to another in NodeJS?

喜你入骨 提交于 2020-04-16 03:41:25
问题 I have two nodeJS servers, Server 1 gets requests from the client and passes it to server 2 which returns a response to server 1 and it responds to the client. The client uploads a file and it has to be passed the same way as any other rest request that I have. I use axios on server 1 to send the data to server2 and multer on server 2 to store the file on disk. I have an issue sending the request from server1 to server2 because the body of the request contains nothing and the request is

How to pass multipart request from one server to another in NodeJS?

孤街浪徒 提交于 2020-04-16 03:41:06
问题 I have two nodeJS servers, Server 1 gets requests from the client and passes it to server 2 which returns a response to server 1 and it responds to the client. The client uploads a file and it has to be passed the same way as any other rest request that I have. I use axios on server 1 to send the data to server2 and multer on server 2 to store the file on disk. I have an issue sending the request from server1 to server2 because the body of the request contains nothing and the request is

multipart/form-data enctype ignored

梦想与她 提交于 2020-03-26 07:52:09
问题 I have defined a form as multipart/form-data enctype. When I press a command button the request is not send with 'multipart/form-data' content-type. <h:form id="form" method="post" enctype="multipart/form-data"> <input type="file" ></input> <p:commandButton id="save" icon="saveBt" value="#{msgs.saveBt}" ... /> </h:form> In the developer tools console I can see the Content-Type as application/x-www-form-urlencoded; charset=UTF-8. I'm working with JSF 2.1 and Primefaces 5.1. Thanks 回答1: You are

Empty MultipartFile[] when sending files from Vue to SpringBoot controller

匆匆过客 提交于 2020-03-05 06:06:43
问题 I'm doing a program that will help me to make monthly reports and I stuck at uploading photos which I need for one kind of the reports. For some reason, it doesn't get an array in the controller. I use Springboot RestController at the backend and Vue with BootstrapVue and vue-resource on the other side. index.html (BootstrapVue): <b-form-file v-model="photos" accept="image/*" multiple placeholder="..." ></b-form-file> <b-button @click="uploadPhotos">Upload</b-button> inside vuemain.js: data: