multipartform-data

Android twitter4j upload image

孤人 提交于 2019-11-27 00:39:21
问题 I have an android app through which I can successfully update the twitter status. I am using it to share links to a webpage which displays an image. I think it will be nice to have a scaled down preview of the image along with the tweet the same way instagram does. How do I upload this image along with my tweet? 回答1: I had the same requirement sometimes back and finally come with the function may be it will help you too. /** * To upload a picture with some piece of text. * * * @param file The

Upload image with multipart form-data iOS in Swift

梦想与她 提交于 2019-11-27 00:32:10
i am having a problem with uploading image with multipart-form here is my code i used from this answer var request = NSMutableURLRequest(URL: url!) request.HTTPMethod = "POST" var boundary = generateBoundaryString() request.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type") var body = NSMutableData() if self.img.image != nil { var imageData = UIImagePNGRepresentation(self.img.image) if imageData != nil { body.appendString("--\(boundary)\r\n") body.appendString("Content-Disposition: form-data; name=\"image\"; filename=\"image.png\"\r\n") body.appendString(

How do I receive a file upload in spring mvc using both multipart/form and chunked encoding?

落花浮王杯 提交于 2019-11-27 00:18:52
问题 I am trying to write a spring mvc method that can receive either a multipart/form or transfer-encoding chunked file upload. I can write a separate method to handle each type but I'd like to do it with the same method so i can use the same REST POST uri such as: http://host:8084/attachments/testupload Here is my best attempt so far: @RequestMapping(value = { "/testupload" }, method = RequestMethod.POST, produces = "application/json") public @ResponseBody ResponseEntity<MessageResponseModel>

How can I rewrite this CURL multipart/form-data request without using -F?

馋奶兔 提交于 2019-11-26 23:57:03
问题 How can I rewrite the following CURL command, so that it doesn't use the -F option, but still generates the exact same HTTP request? i.e. so that it passes the multipart/form-data in the body directly. curl -X POST -F example=test http://localhost:3000/test 回答1: Solved: curl \ -X POST \ -H "Content-Type: multipart/form-data; boundary=----------------------------4ebf00fbcf09" \ --data-binary @test.txt \ http://localhost:3000/test Where test.txt contains the following text, and most importantly

Download file via jquery ajax post

二次信任 提交于 2019-11-26 23:10:03
问题 I am trying to export my web page data and download it as excel file. but the download does not start even the response return succeed. $.ajax({ type: "POST", url: _url, contentType: 'multipart/form-data;boundary=SzB12x', data: json, }); The responseText something like this: PK�J;Fxl/theme/theme1.xml�YOo�6� ���,[r��n;v��i����#-�kJH:�oC{0 X7�2 ��mZ ���d��u@�(٦b:M���� �����{|��^�0t@��*"w$�!0I�[�՚n�i��'����iH� g�,��|�J�!���hRh�h��?r&�L ���߶S��v@���#��׮�"���}��Жt%�hR�t"������+����� ���u{ނ��0K��

How can I handle multipart/form-data POST requests in my java servlet?

天涯浪子 提交于 2019-11-26 22:03:27
问题 I'm having a very hard time dealing with multipart/form-data requests with my java application server. From what I have found out, the servlet 3.0 specification provides methods such as HttpServletRequest.getParts(), which would be ideal for processing the form data uploaded to my servlet. However, this method is part of the 3.0 servlet specification, and my application server (Tomcat 6) does not support this yet. Even with a valid 3.0 web.xml file and the java EE 6 libs, I get the following

How to set up a Web API controller for multipart/form-data

和自甴很熟 提交于 2019-11-26 22:02:23
I am trying to figure this out. I was not getting any useful error messages with my code so I used something else to generate something. I have attached that code after the error message. I have found a tutorial on it but I do not know how to implement it with what I have. This is what I currently have: public async Task<object> PostFile() { if (!Request.Content.IsMimeMultipartContent()) throw new Exception(); var provider = new MultipartMemoryStreamProvider(); var result = new { file = new List<object>() }; var item = new File(); item.CompanyName = HttpContext.Current.Request.Form[

webservice with a file inputstream and a json body?

允我心安 提交于 2019-11-26 21:56:54
问题 I would like to implement a webservice with cxf to upload a file with some informations about it contained in the body. What I've done but didn't work yet : @POST @Path("/") @Consumes(MediaType.MULTIPART_FORM_DATA) User addDocument( @Multipart(value="metadata", type="application/json") DocMeta metadata, @Multipart(value="inputstream", type="multipart/form-data") InputStream inputStream) throws ObjectAlreadyExistsException; When I try to request my service with curl it doesn't work : curl http

Apache HttpClient making multipart form post

天涯浪子 提交于 2019-11-26 21:29:54
I'm pretty green to HttpClient and I'm finding the lack of (and or blatantly incorrect) documentation extremely frustrating. I'm trying to implement the following post (listed below) with Apache Http Client, but have no idea how to actually do it. I'm going to bury myself in documentation for the next week, but perhaps more experienced HttpClient coders could get me an answer sooner. Post: Content-Type: multipart/form-data; boundary=---------------------------1294919323195 Content-Length: 502 -----------------------------1294919323195 Content-Disposition: form-data; name="number" 5555555555 --

Webapi ajax formdata upload with extra parameters

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 21:23:18
问题 I'm using jQuery ajax to upload file but want to add some parameters on webapi method, here is: var data = new FormData(); data.append("file", $("#file")[0].files[0]); data.append("myParameter", "test"); // with this param i get 404 $.ajax({ url: '/api/my/upload/', data: data, cache: false, contentType: false, processData: false, type: 'POST', success: function (data) { console.log(data); } }); The Webapi controller: public class MyController : ApiController { public string Upload(string