multipartform-data

JSP: Best practices uploading files to server

让人想犯罪 __ 提交于 2020-01-02 06:51:11
问题 I am uploading files using multipart form, Apache FileUpload, etc. It work fine. But, I want to know what are the best practices or common practices when saving files in server, according to following: Naming the files in server (i.e.: What name is better? Some UUID generated, or the row ID generated by db table when I insert the file associated data) The best location for files inside the server (What is better? i.e. In linux server which folder or partition I should use. Do I have to

How do I make soapUI attachment paths relative?

烂漫一生 提交于 2020-01-02 05:20:09
问题 I'm using soapUI to test an HTTP server. I need to send a multipart/form-data request, and the request works fine when I go through the file chooser and attach it, but it's saving the path as an absolute path, and I need to save a path relative to my test file (but not cached IN my test file). How can I do this? FYI, I'm using SoapUI 4.0.1 free edition and I am willing to using a groovy coding step if I could figure out how to access the attachment path from it. 回答1: OK, I solved this by

Parsing multipart/form-data using Apache Commons File Upload

微笑、不失礼 提交于 2020-01-02 04:55:11
问题 Does Apache Commons File Upload package provides a generic interface to stream parse multipart/form-data chunks via InputStream , appending Array<Byte> , or via any other generic streaming interface? I know they have a streaming API but the example only shows you how to do that via ServletFileUpload , which I reckon must be specific to Servlet . If not, are there any other alternative frameworks in JVM that lets you do exactly this? Sadly, the framework that I am using, Spray.io, doesn't seem

Postman: Required request part 'file' is not present

烈酒焚心 提交于 2020-01-02 03:39:06
问题 I wanted to upload an image to my Rest API through postman. I am using spring boot framework. Here is the screen shot: I also have not set any any headers as I found in other stack overflow answers that it gives multipart boundary error. Now, below is my controller code: package com.practice.rest.assignment1.controller; import java.io.IOException; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable;

Curl post with multipart/form-data and JSON

巧了我就是萌 提交于 2020-01-02 02:59:09
问题 Is there a way to use curl to do a multipart/form-data post and specify that the data is application/json ? It doesn't have to be curl. 回答1: This is what I use, and it works fine curl -v -H "Content-Type:multipart/form-data" -F "someName={\"your\":\"json\"};type=application/json" Note: I'm on Windows, hence the requirement for double quotes Or -F "someName=@someJsonFile.json;type=application/json" 来源: https://stackoverflow.com/questions/29563907/curl-post-with-multipart-form-data-and-json

iOS, upload file with multipartform-data

試著忘記壹切 提交于 2020-01-01 19:01:15
问题 I would like to upload file to HTTP server. I do it like that right now: NSString *boundary = @"*****"; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; [request setURL:[NSURL URLWithString:@"http://someUploadScript.php"]]; [request setHTTPMethod:@"POST"]; NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary]; [request setValue:contentType forHTTPHeaderField: @"Content-Type"]; [request setValue:@"Keep-Alive" forHTTPHeaderField: @

Parse multipart/form-data using cgi.FieldStorage; None keys

霸气de小男生 提交于 2020-01-01 09:22:51
问题 The following piece of code should be able to run in Python 2.7 and Python 3.x. from __future__ import unicode_literals from __future__ import print_function import cgi try: from StringIO import StringIO as IO except ImportError: from io import BytesIO as IO body = """ --spam Content-Disposition: form-data; name="param1"; filename=blob Content-Type: binary/octet-stream value1 --spam-- """ parsed = cgi.FieldStorage( IO(body.encode('utf-8')), headers={'content-type': 'multipart/form-data;

Making a multipart post request with compressed jpeg byte array with spring for android

霸气de小男生 提交于 2020-01-01 04:56:22
问题 I've been using spring for android successfully in my android app to get/post data from/to the server. Now, I have to do a post request for a multipart form , but I've been unable to get it working the way I want. Use case: 1. Pick a photo from the gallery 2. Load it to a bitmap using the file source 3. Compress the bitmap to a ByteArrayOutputStream 4. Pass the byte array ( ByteArrayOutputStream.toByteArray() ) to the server. (I need to send this as jpeg not application/octet-stream) The

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

旧城冷巷雨未停 提交于 2019-12-30 10:49:25
问题 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

set content-type to utf-8 with angularjs $http

懵懂的女人 提交于 2019-12-30 07:03:48
问题 I'm uploading a form with files, text etc to the appengine blobstore: $http({ method: 'POST', url: the_url, transformRequest: formDataObject, data: event, headers: {'Content-Type': undefined} }) The request sends successfully with the follwing header: Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryYeRxOO7y3qHNWd83 When I try setting the content-type to "multipart/form-data;charset=UTF-8" I lose the boundary and get an error in the response: Bad content type. Please use