multipartform-data

Spring boot multipart/related mime type support

醉酒当歌 提交于 2019-12-01 11:01:35
I need to consume a request whose content-type is multipart/related. Request will consist of image, json payload and binary content. I tried to find some example on how to handle such request in a Spring boot application, I found some references on how to handle multipart/form-data request but nothing related to multipart/related mime type. Request is something like this: POST /upload Content-Type: multipart/related; boundary="123asdf234" --123asdf234 Content-Type: application/json; charset=UTF-8 Content-Disposition: form-data { "json": "payload" } —-123asdf234 Content-Type: application/zip

Posting an object and a file in the same call to the server with jQuery.ajax

你。 提交于 2019-12-01 10:05:17
问题 I'm trying to make a client side post to the following MVC action method: [HttpPost] public void Create(ProductModel product, HttpPostedFileBase imageFile) { productServices.AddProduct(product, imageFile); } This is straightforward with a type="submit" button, however in my particular case I need to do it with an ajax call. I can just pass the ProductModel as JSON easy enough. $.ajax({ url: '/Product/Create', type: 'POST', data: JSON.stringify({product: { Id: 1, Name: "SomeName" } }),

How do I display validation errors about an uploaded multipart file using Spring MVC

守給你的承諾、 提交于 2019-12-01 09:14:15
I have a Spring MVC application with a file upload form . I would like to be able to display validation errors to a user if the uploaded content is not valid (e.g. the content is not an image, etc.) However, by definition what is posted is of type: MultipartFile ( multipart/form-data ) and therefore I can't have a @ModelAttribute in my form and in order to use a BindingResult , it seems I do need a @ModelAttribute just before the BindingResult . My question is then, what is the most appropriate way of displaying validation errors to a user when all I have is a MultipartFile ? I could of course

TypeError: Cannot read property 'image' of undefined

匆匆过客 提交于 2019-12-01 09:04:10
问题 There is something wrong in my source code but I'm not able to figure out what - please help. I was looking for some solutions found some and updated source code according them but didn't help. var express = require('express'); var fs = require('fs'); var bodyParser = require('body-parser'); var app = express() app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: false })); var form = "<!DOCTYPE HTML><html><body>" + "<form method='post' action='/upload' enctype='multipart

Using Alamofire and multipart/form-data

痴心易碎 提交于 2019-12-01 08:26:26
I'm unable to approach the API that has been offered to me in the proper way for it to give me the response I'm looking for. I've been using Swift and Alamofire for a while but this is the first time I've to upload images using multipart/form-data. I'm able to upload images using Postman but I'm unable to get the same message send out by my application using the Alamofire framework. My Swift code: func postFulfilWish(wish_id: Int, picture : UIImage, completionHandler: ((AnyObject?, ErrorType?) -> Void)) { var urlPostFulfilWish = Constant.apiUrl; urlPostFulfilWish += "/wishes/";

Using Alamofire and multipart/form-data

冷暖自知 提交于 2019-12-01 07:03:35
问题 I'm unable to approach the API that has been offered to me in the proper way for it to give me the response I'm looking for. I've been using Swift and Alamofire for a while but this is the first time I've to upload images using multipart/form-data. I'm able to upload images using Postman but I'm unable to get the same message send out by my application using the Alamofire framework. My Swift code: func postFulfilWish(wish_id: Int, picture : UIImage, completionHandler: ((AnyObject?, ErrorType?

Android : Upload large files using MultipartEntity

本秂侑毒 提交于 2019-12-01 06:26:50
问题 According this answer "Android upload video to remote server using HTTP multipart form data" I do all steps. But I don't know how I code for server side! I mean a PHP simple page that serve my reauest foe upload. And another question is that : YOUR_URL (3rd line of following snippet) must be address of that PHP page? private void uploadVideo(String videoPath) throws ParseException, IOException { HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(YOUR_URL);

Curl -F equivalent in C#

不想你离开。 提交于 2019-12-01 05:51:23
I am trying to use HTTPClient object in C# to send a post request to an API. This is the CURL command: curl -X POST https://zzz.zzz.zzz/yyy -F Key=abcd -F media=@"audio.aac" I wrote the following code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Net.Http; using System.IO; using System.Net.Http.Headers; namespace Speech2Text { class Program { static void Main(string[] args) { curl().Wait(); } static async Task curl() { var client = new HttpClient(); //Create List of KeyValuePairs List<KeyValuePair<string,

Is it possible to send a String[] through Multipart using Retrofit?

故事扮演 提交于 2019-12-01 05:25:15
I'm developing an application where at a point the user has to choose any number of countries from a list and I must send the selected names through a multipart. I am not uploading any file along with the String[], but there is no route to upload information without it being a multipart and I don't have any saying in how the web server operates. I've attempted to simply send it as an Array, ArrayList and JsonArray as such: @Headers({ "Connection: Keep-Alive", }) @Multipart @PUT("/user/{id}") String updateUser(@Path("id") int userId, @Part("user[countries]") String[] countries); I've also

does maxPostSize apply to multipart/form-data file uploads

为君一笑 提交于 2019-12-01 03:28:04
I have a webapp on a Tomcat server that allows files to be uploaded. There is a limit on the size of a file upload, and I'd like that limit to be enforced preemptively (ie, once you cross the limit, the file upload fails, rather than transferring the whole file, checking that it's too big and then sending an error). I tried to do this by add maxPostSize="1000" to the connector section in the relevant connector in server.xml, but I can still upload larger files. I've seen a post indicating that maxPostSize only works for a specific content type. So my question is whether what I'm doing is