multipartform-data

ImageIO.read( ) always rotates my uploaded picture

拟墨画扇 提交于 2019-12-03 06:47:48
I want to create a web application that allow users to upload their image to the server. When they click send, their image will be uploaded to the server (multipart). Before saving, I want to make some operation with the image, so I decided to use .. ImageIO.read(InputStream) to get BufferedImage object here is the code: public static BufferedImage getBufferedImageFromMultipartFile(MultipartFile file) throws APIException { BufferedImage bi = null; try { bi = ImageIO.read(file.getInputStream()); } catch (IOException e) { throw new APIException(ErrorCode.SERVER_ERROR, e); } return bi; } The

Android Multipart HTTP Post does not send the File's MIME type

旧城冷巷雨未停 提交于 2019-12-03 06:17:35
Trying to figure what's wrong with my codings. I followed a blog post from here . I managed to get the codes to actually upload the file to a PHP web service. However, for some reason although I've set explicitly the MIME type for the file, PHP shows that the MIME is just a blank string and therefore rejected. Here's my codings: public String SendPost(String fn, String bid, String caption, String uid, String APIKey, String postHash) throws ParseException, ClientProtocolException, IOException { HttpClient httpclient = new DefaultHttpClient(); httpclient.getParams().setParameter

Retrofit 2 Multipart POST request sends extra quotes to PHP

烈酒焚心 提交于 2019-12-03 06:00:18
Using Retrofit 2.0.1, there is a call function in my API interface defined in Android App: @Multipart @POST("api.php") Call<ResponseBody> doAPI( @Part("lang") String lang, @Part("file\"; filename=\"image.jpg") RequestBody file ); I send the request like this: Call call = service.doAPI("eng", imageFile); where imageFile is a RequestBody created with a File object. The upload image part has no problem, while the @Part("lang") String lang part got extra quotes in server. In PHP side, it is written as follow: $lang = trim($_POST['lang']); which returns "eng" . Why there is an extra double quote

Play Framework Testing using MultipartFormData in a FakeRequest

帅比萌擦擦* 提交于 2019-12-03 05:54:23
I am currently in the process of writing some Specs2 tests for may Play Framework 2.2.x application which accepts MultipartFormData submissions as part of it's function. I have successfully written other tests with text and JSON bodies using the following form: "respond to POST JSON with description field present" in { running(FakeApplication()) { val response = route(FakeRequest(POST, "/submission.json").withJsonBody(toJson(Map("content" -> toJson("test-content"), "description" -> toJson("test-description"))))).get status(response) must equalTo(OK) contentType(response) must beSome.which(_ ==

multipart File uploads using NodeJS

醉酒当歌 提交于 2019-12-03 05:49:42
I am having troubles getting file uploads to work with NodeJS. I am using Dropzone.JS to create a form that sends a POST request to /file-upload here: <form action="/file-upload" class="dropzone dragndrop" id="my-awesome-dropzone"></form> Then I have a route in app.js: app.post('/file-upload', routes.upload); Then my handler: exports.upload = function(req, res){ console.log(req.files); res.send("OK"); } However, the upload function here is never called. The server crashes with this error first: events.js:69 throw arguments[1]; // Unhandled 'error' event ^ Error: Invalid data at WriteStream.

In NetSuite with SuiteScript 2.0 unable to send a file with HTTP POST request with a content-type multipart/form-data

♀尐吖头ヾ 提交于 2019-12-03 05:04:05
I am not able to send my "multipart/form-data' file to this API. If I use POSTMAN it's working but with the https post method it seems that netsuite doesn't recognize the "form-data" content-type. Somebody knows how to send a form-data with SuiteScript 2 ? Here is a part of my code: var fileObj = file.create({ name: invoiceNumber + '_ubl.xml', fileType: file.Type.XMLDOC, contents: einvoicecontentwithpdf, folder : 120, isOnline : false }); var headers = { 'Authorization': 'Basic xxxxxxxxxxxxxxxxxxxxx', 'Content-Type': 'multipart/form-data' }; var response = https.post({ url: 'https://community

GAE/J: How do I POST a Multipart MIME message from appengine to facebook

自古美人都是妖i 提交于 2019-12-03 03:41:01
I want to post a photo (stored in appengine db) to facebook. To test I've got the basic understanding down locally: I've been successful with this form: <form action="https://graph.facebook.com/7378294228/photos?access_token=AAAAAJPBSAzcBALmz7GOLZCER7Pc2347WQIDIlIFR8e2imWUzeuCKRLrXjAqR6zjaUb4laqkLtJlQlYa7X5ZBd2aNJoLom8M7IlvHfw39QZDZD" method="POST" enctype="multipart/form-data"> <input type="file" name="source" id="source"/> <input type="text" name="message" value="mymess"/> <input type="Submit"/> </form> (I grabbed the access_token from a recent session to make this work.) Here's what I've

How to submit multipart formdata using jquery

☆樱花仙子☆ 提交于 2019-12-03 03:13:39
<form id="uploadForm" enctype="multipart/form-data" action="http://localhost:1337/ad/upload" method="post" name="uploadForm" novalidate> <input type="file" name="userPhoto" id="userPhoto" /> <input type="submit" value="submit" id="uploadImage" /> </form> This is my html form which accepts an image as file inout, the user can select an image file and then click submit. This works but the url of the current page changes to localhost:1337/ad/upload. I want the page to stay at the same url. $("form#uploadForm").submit(function(event) { event.preventDefault(); var formData = new FormData($(this)[0]

Spring Controller @RequestBody with file upload is it possible?

两盒软妹~` 提交于 2019-12-03 03:06:40
问题 I have a Controller like this and I want to submit a form with file uploading as well as some form data like label as shown below. Also, I want to do that using @RequestBody so I can use the @Valid annotation on the wrapper as more variables will be added. public @ResponseBody WebResponse<Boolean> updateEUSettings( final Locale locale, @Validated @ModelAttribute final EUPSettingsWrapper endUserPortalSettingsWrapper) { } And my wrapper is: public class EUPSettingsWrapper { private String label

Is there a lightweight multipart/form-data parser in C or C++? [closed]

混江龙づ霸主 提交于 2019-12-03 02:42:16
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . I'm looking at integrating multipart form-data parsing in a web server module so that I can relieve backend web applications (often written in dynamic languages) from parsing the multipart data themselves. The multipart grammar (RFC 2046) looks non-trivial and if I implement it by hand a lot of things can go wrong