multipartform-data

How to add custom header to retrofit request body part?

江枫思渺然 提交于 2019-12-06 06:49:51
问题 So I am building a multipart request using retrofit and I want to add a custom header to one one of the part. I have tried a lot of things but nothing seems to be working. The photo shows a body request that contains 4 parts. Each part contains a body and a header, what I want is to add a custom header to the selected part. How can I do that? 回答1: So just to answer my own question, I create a part with an image and a custom header like this: MultipartBody.Part body = MultipartBody.Part.create

Spring Boot (1.2.5.RELEASE) Resttemplate Multipart File Upload UTF-8 Filename not possible

感情迁移 提交于 2019-12-06 06:43:10
I have a Spring Boot Rest Service which uploads a file via the RestTemplate exchange method. The upload is working as it should but there is a problem with utf-8 filenames which for example contain german umlauts like äöü. When uploading a file from a HTML5 App it is working without any problem so it is not a problem at the receiving service. Without setting any encoding for the MultipartCharset the umlauts are replaced by "?" (e.g. Überschrift.txt gets ?berschrift.txt), as US-ASCII is used for the filename encoding. I tried setting the MultipartCharset to UTF-8 with this code: (

Uploading image and data as multi part content - windows phone 8

陌路散爱 提交于 2019-12-06 06:29:45
I am unable to upload image and data to web service as multipart content.Here is my code var fileUploadUrl = @"http://myurl"; var client = new HttpClient(); client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "multipart/form-data"); photoStream.Position = 0; // This is the postdata MultipartFormDataContent content = new MultipartFormDataContent(); content.Add(new StreamContent(photoStream), "attendeedImage"); content.Add(new StringContent("12", Encoding.UTF8), "userId"); content.Add(new StringContent("78", Encoding.UTF8), "noOfAttendees"); content.Add(new StringContent(

How to parse Multi-part form data in an Azure Function App with HTTP Trigger? (NodeJS)

安稳与你 提交于 2019-12-06 06:07:13
问题 I want to write a NodeJS HTTP endpoint using Azure Functions. This endpoint will be a POST endpoint which takes files and upload these to blob storage. However, NodeJS multipart form data parsers are all in the form of httpserver or expressJS middleware. Is there any available tools that can parse the multipart form data after it has all been received from the Function Application's wrapper? Thanks! 回答1: As Azure Functions has wrapped http server object in Node.js, and exposes a simple req

How to send a buffer in form-data to SignServer?

Deadly 提交于 2019-12-06 05:11:11
问题 I have a file in memory (in a buffer), it doesn't exist on the file system (so I can't just stream that). I'm trying to send it to SignServer using HTTP. Here's how I try to do it: var formdata = require('form-data'); var form = new formdata(); form.append('workerName', 'PDFSigner'); form.append('data', file_buffer); // or // escape(file_buffer.toString('binary')) // or // file_buffer.toString('binary') (without escaping) var request = form.submit('http://localhost:8080/signserver/process',

How to send file along some POST variables with Objective-C iPhone SDK?

可紊 提交于 2019-12-06 04:13:51
I'd like to know {insert_title_here}? I use this method, but with no success: //string data NSString *post = @"message=helloWorld"; NSData *postData = [post dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES]; //file data NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *fullPathToFile = [documentsDirectory stringByAppendingPathComponent:@"ImageFile.png"]; NSData *imageData = [[NSData alloc] initWithContentsOfFile:fullPathToFile]; //request NSMutableURLRequest *request

Glassfish - uploading images - doing it right

隐身守侯 提交于 2019-12-06 04:10:14
问题 I am on latest glassfish (3.1.2) - so no need for apache FileItem and no bugs with getPart(). I read that the best practice on uploading images is saving them on the file system (see here for instance). I am editing already existing code - smelly at that - so I had the idea to do : Part p1 = request.getPart("file"); System.out.println("!!!!!P1 : " + p1); Prints : !!!!!P1 : File name=DSC03660.JPG, StoreLocation=C:\_\glassfish3\glassfish\domains\domain1\generated\jsp\elkethe\upload_7cb06306

Webflux multipart/form-data, csrf enabled, with and without file upload getting Invalid CSRF Token

放肆的年华 提交于 2019-12-06 03:34:37
With csrf disabled I can upload file however I need it enabled. The problem only occurs when the form enctype is multipart/form-data, namely 'Invalid CSRF Token' with 403. Generally when I set the enctype as multipart/form-data even for a form without file upload, I get the same error. Using this dependency: <dependency> <groupId>org.synchronoss.cloud</groupId> <artifactId>nio-multipart-parser</artifactId> <version>...</version> </dependency> Tried including hidden csrf input in the form and also tried appending it to the url but same error <form method="post" th:action="${'/add/' + id + '

Post Method + WinHttpRequest + multipart/form-data

北战南征 提交于 2019-12-06 03:05:00
I'm stumped why this doesn't work can't seem to find any problems. Here is the code. Public Const MULTIPART_BOUNDARY = "speed" Function getBalance() As String Dim sEntityBody As String Dim postBody() As Byte Dim username As String Dim password As String username = CStr(frmMain.txtUser.text) password = CStr(frmMain.txtPass.text) sEntityBody = "--" & MULTIPART_BOUNDARY & vbCrLf sEntityBody = sEntityBody & "Content-Disposition: form-data; name=""function""" & vbCrLf & vbCrLf & "balance" & vbCrLf sEntityBody = sEntityBody & "--" & MULTIPART_BOUNDARY & vbCrLf sEntityBody = sEntityBody & "Content

Content type for file part of the multipart/form-data request is set wrong by the client

谁说胖子不能爱 提交于 2019-12-06 02:56:16
I'm trying to send multipart/form-data with following JavaScript and jQuery: var formData = new FormData(); formData.append("projectName", $("#projectNameInput").val()); var file = $("#fileInput")[0].files[0]; formData.append("content", file); var xhr = new XMLHttpRequest(); xhr.open('POST', '/project', true); xhr.onload = function(ev) { // Handling logic omitted }; xhr.send(formData); However, some client browsers (Firefox and Chrome) receive 400 Bad Request from the server. While examining the headers and request payload I discovered that some browsers set explicit content type for the file