multipartform-data

Send multipart/form-data content type request

独自空忆成欢 提交于 2019-11-29 03:42:24
问题 The follow http post request send data using multipart/form-data content type. -----------------------------27311326571405\r\nContent-Disposition: form-data; name="list"\r\n\r\n8274184\r\n-----------------------------27311326571405\r\nContent-Disposition: form-data; name="list"\r\n\r\n8274174\r\n-----------------------------27311326571405\r\nContent-Disposition: form-data; name="list"\r\n\r\n8274178\r\n-----------------------------27311326571405\r\nContent-Disposition: form-data; name=

Wrong Content-Type header generated using MultipartFormDataContent

萝らか妹 提交于 2019-11-29 03:37:53
I have the following code: private static string boundary = "----CustomBoundary" + DateTime.Now.Ticks.ToString("x"); private static async Task<string> PostTest() { string servResp = ""; using (var content = new MultipartFormDataContent(boundary)) { content.Add(new StringContent("105212"), "case-id"); content.Add(new StringContent("1/14/2014"), "dateFrom"); content.Add(new StringContent("1/15/2014"), "dateTo"); HttpClientHandler handler = new HttpClientHandler(); cookieContainer = new CookieContainer(); handler.CookieContainer = cookieContainer; HttpRequestMessage request = new

PHP Curl post with file attachment; custom content-type header

心已入冬 提交于 2019-11-29 03:16:45
问题 I have to post a file to a server along side with a few post params. The documentation I received from this server admin shows an example of what the post request is supposed to look like ( * NOTE the custom content type for the POST "multipart/x-api-remote-integration"): POST /gateway/remote_send HTTP/1.0 Content-Type: multipart/x-api-remote-integration; boundary=ABC1234 Content-Length: 323 --ABC1234 Content-Type: application/x-www-form-urlencoded profile_name=username&profile_pw

What is the '-' in multipart/form-data?

我的梦境 提交于 2019-11-29 01:31:38
I want to ask a question about the multipart/form data. I find the http header of multipart post and the Content-Type: multipart/form-data; boundary=-----...---boundaryNumber. I want to ask, how many of '-' between the boundaryNumber and '='? Not a single - is mandatory. You can have any number of them. It is actually a mystery to me why user-agents tend to add so many. It is probably traditional because in the old days, when people still regularly looked at the actual protocol traffic, it provided some nice visual separation. Nowadays it is pointless. Note however, that when you use the

Jersey service file upload causes OutOfMemoryError

折月煮酒 提交于 2019-11-29 01:31:18
I'm developing form submission service with Jersey 2.0. The form includes several text fields and one file field. I need to extract file , file name , file media type and file content type and save them in object store. @Path("upload") @Consumes({MediaType.MULTIPART_FORM_DATA}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public class UploadService { @POST public BlobDo uploadFile(FormDataMultiPart uploadedBody) { String accountSid = uploadedBody.getField("account-sid").getValue(); String apiToken = uploadedBody.getField("api-token").getValue(); String checksum =

How to send Multipart form data with restTemplate Spring-mvc

有些话、适合烂在心里 提交于 2019-11-29 01:10:15
I am trying to upload a file with RestTemplate to Raspberry Pi with Jetty. On Pi there is a servlet running: protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { PrintWriter outp = resp.getWriter(); StringBuffer buff = new StringBuffer(); File file1 = (File) req.getAttribute("userfile1"); String p = req.getParameter("path"); boolean success = false; if (file1 == null || !file1.exists()) { buff.append("File does not exist\n"); } else if (file1.isDirectory()) { buff.append("File is a directory\n"); } else { File outputFile = new File(req

Upload large file with progress bar and without OutOfMemory Error in Android

蓝咒 提交于 2019-11-29 00:03:01
问题 I am having some problem while uploading large video file(upto 150MB) 1.When I use this code Link1 .I able to upload small file with progress bar ,but as my file is large so android give me OutOfMemory Error . 2.If I use this code Link2. i am able to upload large file(this is really a good solution) but don't know how to show progess(like 20% complete or 80% complete and so on).so Please guide me. 回答1: Finally I got solution of my question I want to share it ... 1.First solution Link1 This

Java 9 HttpClient send a multipart/form-data request

不羁岁月 提交于 2019-11-28 23:51:17
Below is a form: <form action="/example/html5/demo_form.asp" method="post" enctype=”multipart/form-data”> <input type="file" name="img" /> <input type="text" name=username" value="foo"/> <input type="submit" /> </form> when will submit this form, the request will look like this: POST /example/html5/demo_form.asp HTTP/1.1 Host: 10.143.47.59:9093 Connection: keep-alive Content-Length: 326 Accept: application/json, text/javascript, */*; q=0.01 Origin: http://10.143.47.59:9093 X-Requested-With: XMLHttpRequest User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)

Sending files /file upload using ajax which works in IE9

泄露秘密 提交于 2019-11-28 23:33:22
I need to upload files using ajax which has to be supported in IE9. I was using FormData as mentioned here . My code looks like this: var files = new FormData(); JQuery.each($('#file')[0].files, function (i, file) { files.append('file', file); }); $.ajax({ type: "POST", url: '/url', cache: false, contentType: false, processData: false, data: files, ... }); This works fine in Safari and Firefox, but fails in IE9 as the FormData is not supported in IE9. I tried sending just as a file by setting: data: $('#file')[0].files[0] contentType: 'multipart/form-data' This fails as the data is sent in url

The temporary upload location is not valid

空扰寡人 提交于 2019-11-28 23:24:48
I'm developing a web app with Java and Spring MVC (and hibernate to link to a MySQL database). I tried numerous ways to get my application to upload files. Unfortunately, I've encountered an error that says my temporary upload location is not valid . As a workaround, I've tried several locations like C:\Temp\ C:\temp\ C:/temp/ /WEB-INF/tmp C:\Users\Default\AppData etc Here is the error I'm getting org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is java.io.IOException: The temporary upload location [C:\Users\take\eclipse\sts