multipartform-data

Javascript/HTML5 file API reading sequential files into multipart form data

百般思念 提交于 2019-11-29 22:11:07
问题 I'm using the HTML5 File API to assemble multipart form data for submission by XHR to a web service. I have the whole thing working in FF, which has a nice convenient getAsBinary() method included in their implementation of the file API. This was a pretty sweet deal. It basically went: var const; // constructor const += headers; const += field_data; for(var i = 0; i < files.length; i++) { const += files[i].getAsBinary(); } sendData(const); Worked like a charm. To get it working in Chrome,

Cordova File Transfer remove Multipart or Content-Disposition Header

家住魔仙堡 提交于 2019-11-29 17:29:30
I managed to upload an image to my server using Cordova File Transfer plugin. var img = <full path to image> var url = <url to webservice> var options = new FileUploadOptions(); //no specified options, using defaults var ft = new FileTransfer(); ft.upload(img, encodeURI(url), win, fail, options); var win = function (r) { console.log('Successfully sent'); } var fail = function (error) { console.log("An error has occurred: Code = " + error.code); }; However, my server had problems reading the image due to the extra header added by the plugin. --+++++..Content-Disposition: form-data; name="file";

React.js, how to send a multipart/form-data to server

我们两清 提交于 2019-11-29 17:27:08
问题 We want to send an image file as multipart/form to the backend, we try to use html form to get file and send the file as formData, here are the codes export default class Task extends React.Component { uploadAction() { var data = new FormData(); var imagedata = document.querySelector('input[type="file"]').files[0]; data.append("data", imagedata); fetch("http://localhost:8910/taskCreationController/createStoryTask", { mode: 'no-cors', method: "POST", headers: { "Content-Type": "multipart/form

parsing a formdata object with javascript

蓝咒 提交于 2019-11-29 16:54:38
My company uses a propitiatory application server in which the server side programs are written in javascript (not node.js) . This is a very initial thing and support isn't that good Now here is my problem : I am having to process an uploaded csv on the server side .. I am using the super answer at How can I upload files asynchronously? (passing the formdata object with jquery) and i am able to access the sent file on the server side . But how do i parse it out ? It looks like this ------WebKitFormBoundaryU5rJUDxGnj15hIGW Content-Disposition: form-data; name="fileToUpload"; filename="test.csv"

How to submit multiple entities to the post method from jersey client program?

北城以北 提交于 2019-11-29 15:22:14
I am trying to pass multiple entities to the web service method. The web service method has two parameters of pojo entity type. I am able to post only one entity to the web service method. I am unable to post multiple entities to the web service method. Server side code: @POST @Path("/test") @Produces(MediaType.APPLICATION_XML) @Consumes(MediaType.APPLICATION_XML) public void testMethod(Emp emp, Student stud){ ... } Client side code: ... ... Emp emp = new Emp; Student stud = new Student(); ClientResponse response = resource.type(MediaType.APPLICATION_XML).entity(emp).entity(stud).post

How to Upload a photo using Retrofit?

江枫思渺然 提交于 2019-11-29 15:18:58
I'm using Retrofit in my Android application to communicate with a REST-API. When user changes his profile picture in my application, I need to send a request and upload new image. This is my service: @Multipart @PATCH("/api/users/{username}/") Call<User> changeUserPhoto(@Header("Authorization") String token,@Path("username") String userName , @Part("photo") RequestBody photo); And this is my code to send request: Retrofit retrofit = new Retrofit.Builder() .baseUrl(GlobalVars.BASE_URL) .addConverterFactory(GsonConverterFactory.create()) .build(); UserService userService = retrofit.create

Spring Boot multipart content type HTTP Request using RestTemplate

*爱你&永不变心* 提交于 2019-11-29 12:07:38
I am trying to emulate this request using RestTemplate in Spring Boot curl -X POST 'https://my.craftar.net/api/v0/image/?api_key=123456789abcdefghijk123456789abcdefghijk' -F "item=/api/v0/item/4fe672886ec142f6ab6d72d54acf046f/" -F "file=@back_cover.png" Here's my code: MultiValueMap<String, Object> params= new LinkedMultiValueMap<>(); params.add("item", "/api/v0/item/4fe672886ec142f6ab6d72d54acf046f/"); final String filename=file.getOriginalFilename(); Resource contentsAsResource = new ByteArrayResource(file.getBytes()){ @Override public String getFilename(){ return filename; } }; HttpHeaders

How to Create a Multipart HTTP Response With ASP.NET Core

只愿长相守 提交于 2019-11-29 12:02:55
问题 I would like to create an action method in my ASP.NET Core controller which returns a Multipart HTTP Response containing several files. I know that using a .zip file is the recommended approach for websites but I am considering using such a request for an API. The examples I have been able to find in the ASP.NET Core samples are to do with multipart HTTP requests when uploading files. In my case, I want to download files. UPDATE I've raised the following GitHub issue: #4933 回答1: I've written

DART post with multipart/form-data

こ雲淡風輕ζ 提交于 2019-11-29 11:42:53
in DART lang, how to specify POST request Content-Type to be multipart/form-data My DART code is: sendDatas(dynamic data) { final req = new HttpRequest(); req.onReadyStateChange.listen((Event e) { if (req.readyState == HttpRequest.DONE && (req.status == 200 || req.status == 0)) { window.alert("upload complete"); } }); req.open("POST", "/upload"); req.send(data); } I am doing POST with a file Robert I think you should use HttpRequest.postFormData(url, data) here. Then you can use the following: FormData data = new FormData(); // from dart:html data.append(key, value); HttpRequest.request('

How to manually create multipart/form-data

旧城冷巷雨未停 提交于 2019-11-29 11:00:06
We can use .formData() of Body mixin to return a FormData representation of data at Chromium (Chrome) 60+ and Firefox 39+ Relevant specifications: 7.2 The Multipart Content-Type Returning Values from Forms: multipart/form-data Errata Clarification of Body package data algorithm with bytes, FormData and multipart/form-data MIME type #392 Documenting de-facto handling of multipart/form-data form field file uploads #3040 Related Multipart HTTP response How to upload files in Web Workers when FormData is not defined How to manually create multipart/form-data using JavaScript at client and at