multipartform-data

Android:How to upload .mp3 file and image to http server?

不打扰是莪最后的温柔 提交于 2019-11-27 18:46:52
问题 My code for uploading image to Server is : String userIdParameter = String.valueOf(userId); String fileName = "temporary_holder.jpg"; HttpURLConnection conn = null; DataOutputStream dos = null; String lineEnd = "\r\n"; String twoHyphens = "--"; String boundary = "*****"; int bytesRead, bytesAvailable, bufferSize; byte[] buffer; int maxBufferSize = 1 * 1024 * 1024; String sourceFileUri = HomeScreen.get_path(); String upLoadServerUri = "http://10.120.10.87:8080/WebImage/UploadImage"; File

Wrong Content-Type header generated using MultipartFormDataContent

醉酒当歌 提交于 2019-11-27 17:39:54
问题 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

Convert JS Object to form data

南笙酒味 提交于 2019-11-27 17:16:36
How can I can convert my JS Object to FormData ? The reason why I want to do this is, I have an object that I constructed out of the ~100 form field values. var item = { description: 'Some Item', price : '0.00', srate : '0.00', color : 'red', ... ... } Now I am asked to add the upload file functionality to my form which, of-course is impossible via JSON and so I am planning on moving to FormData . So is there any way that I can convert my JS object to FormData ? If you have an object, you can easily create a FormData object and append the names and values from that object to formData. You

Node.js File Upload (Express 4, MongoDB, GridFS, GridFS-Stream)

那年仲夏 提交于 2019-11-27 16:29:42
问题 I am trying to setup a file API in my node.js application. My goal is to be able to write the file stream directly to gridfs, without needing to store the file to disk initially. It seems like my create code is working. I am able to save a file upload to gridfs. The problem is reading the file. When I try to download a saved file via a web browser window, I see that the file contents are wrapped with something like the following: ------WebKitFormBoundarye38W9pfG1wiA100l Content-Disposition:

struts2 file upload loosing parameters

淺唱寂寞╮ 提交于 2019-11-27 16:10:28
Using Struts 2.3.15.1 Implementing file upload in struts2. This is something I've done a number of times, however, I'm trying to include some sanity checks (i.e. max file size primarily). I have the fileUpload interceptor in place as the last interceptor in my stack (i.e. struts.xml ). My stack includes a few in-house interceptors as well as the validationWorkflowStack . I've set the following property in my struts.properties file: struts.multipart.maxSize = 2000000 In addition to the file upload, I'm passing a few other params in my form. Form is defined as: <s:form action="addResource"

Jersey service file upload causes OutOfMemoryError

流过昼夜 提交于 2019-11-27 16:01:57
问题 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")

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

依然范特西╮ 提交于 2019-11-27 15:59:43
问题 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 '='? 回答1: 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,

File Upload using HTTPHandler

人走茶凉 提交于 2019-11-27 15:47:08
I am trying to upload file ( multi part form data ) using HTTPHandler. WebKit Boundary is getting written to the destination file , thus corrupting the file. Input files can be any kind of files, including text, zip, apk etc. Code: public void handle(HttpExchange httpExchange) throws IOException { URI uri = httpExchange.getRequestURI(); String httpReqMethod = httpExchange.getRequestMethod(); Headers headers = httpExchange.getRequestHeaders(); InputStream inputStrm = null; FileOutputStream destFile = null; String contentType = ((headers.get("Content-type") != null) ? (headers.get("Content-type"

Parse multipart response for image download in ios

99封情书 提交于 2019-11-27 15:46:53
In my application, I'm downloading image from server as multipart content. In my response data I'm getting 2 parts: one is json content and other is downloaded file. The response is in following format. --poa89012-3212-1232-9201-fdsakjkj921 Content-Type: application/json; charset=utf-8 Content-Disposition: inline; name=info { //json content } --poa89012-3212-1232-9201-fdsakjkj921 Content-Disposition: file; name=file; filename=photo.png Content-Type: application/octet-stream // File data ˘íë77íí77Í¥2008:02:11 11:32:512008:02:1 ------ I'm not able to handle this response which has 2 parts, when

How to send Multipart form data with restTemplate Spring-mvc

早过忘川 提交于 2019-11-27 15:42:10
问题 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