form-data

Uploading FormData from Trigger.io Forge to Amazon S3

青春壹個敷衍的年華 提交于 2019-12-05 02:35:49
问题 I am trying to upload an image file from my Trigger.io mobile app directly to Amazon S3 (see here: http://aws.amazon.com/articles/1434). I'm able to do this on the web without any problems using jQuery and the FormData API as follows: var fd = new FormData(); key = 'test.jpg' fd.append('key', key); fd.append('acl', 'public-read'); fd.append('Content-Type', file.type); fd.append('AWSAccessKeyId', key_id); fd.append('policy', policy_base64); fd.append('signature', signature); fd.append('file',

'FormData' is undefined in IE only

天涯浪子 提交于 2019-12-05 02:00:59
I have a problem where i need to post the data as content-type application/x-www-form-urlencoded . var inputData = {cId:"444",pageNo:"1",latitude:"49.153236",longitude:"12.040905"}; var data = new FormData(); data.append('data', JSON.stringify(inputData)); this.model.save(data, { data: data, processData: false, cache: false, contentType: false, success: function (model, resultData) { $.get(App.baseUrl + 'templates/all-offers-view.html', function (data) { template = _.template(data, { data: resultData }); that.$el.html(template); }, 'html'); }, error: function (error) { console.log("Error");

Sending nested JSON with image

回眸只為那壹抹淺笑 提交于 2019-12-04 19:34:47
I have been trying to research a way to be able to send nested JSON requests via Ajax back to the server. From my understanding formdata that we mostly use for sending images or files to the server wont work in this scenario, since it seems like FormData does not handle nested objects. This is the kind of payload I need to send. Any suggestions? payload = { 'login':{ 'key':'some_key' }, 'user':{ 'doc':{ 'dp':<here will be the image file>, 'date':"some date", 'extra':"extra info" }, 'fingerprint':'some_fingerprint' } } I've never been able to send image data over Json, but I have been able to

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

房东的猫 提交于 2019-12-04 11:17:13
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', function(err, res) {}); When I try appending file_buffer SignServer says that data is empty: Status 400

How to send Array with the formdata in ajax request to mvc action

。_饼干妹妹 提交于 2019-12-04 08:02:12
I was trying to send array with the form data to an action with Ajax request but whenever I do I receive both the form data and the array empty $scope.SubmitForm = function () { var sLangs = $("#supportedLanguages").data("kendoMultiSelect").value(); var formdata = new FormData($('#frmAppSettings').get(0)); alert(formdata.SelectedLanguages); var data = new FormData(document.getElementById("frmAppSettings")); $.ajax({ type: "POST", url: "/AppMenuMaker/AppSettings", data: JSON.stringify({ AppSettingsView: formdata, SelectedLangs: sLangs }), processData: false, contentType: false, success:

angular get image data and again append it to FormData

痞子三分冷 提交于 2019-12-04 04:54:12
In angular 5 I am getting the images for hotelgallery from mongodb through my service. So basically the data what I am getting is like this { fieldname: "hotelgallery", originalname: "e.jpg", encoding: "7bit", mimetype: "image/jpeg", destination: "./public/", encoding : "7bit", filename : "1521139307413.jpg" mimetype : "image/jpeg" path : "public/1521139307413.jpg" size : 66474 } { fieldname: "hotelgallery", originalname: "e.jpg", encoding: "7bit", mimetype: "image/jpeg", destination: "./public/", encoding : "7bit", filename : "1521139307413.jpg" mimetype : "image/jpeg" path : "public

HTML5 FormData file upload with RubyOnRails

人走茶凉 提交于 2019-12-04 04:13:38
I using this script to upload file (one by one) with HTML5 FormData in Rails 3.2.8 application. http://jsfiddle.net/RamPr/ $('.uploader input:file').on('change', function() { $this = $(this); $('.alert').remove(); $.each($this[0].files, function(key, file) { $('.files').append('<li>' + file.name + '</li>'); data = new FormData(); data.append(file.name, file); $.ajax({ url: $('.uploader').attr('action'), contentType: 'multipart/form-data', type: 'POST', dataType: 'json', data: data, processData: false }); }); }); But when I upload a file, I get this error in console: webrick/server.rb:191:in

Using FORM DATA with Alamofire

懵懂的女人 提交于 2019-12-04 03:07:15
I am using alamofire for some time now, but I have never used a form data Post. Now I am stuck. I have 2 params (email, password) and don't know how POST them to server. Can anyone give me an example please? And here is a sample code for Alamofire 4.0 in Swift 3.0 let url = "http://testurl.com" let parameters = [ "email": "asd@fgh.hjk", "password": "55555" ] Alamofire.request(url, method: .post, parameters: parameters, encoding: URLEncoding.default).responseJSON { response in switch response.result { case .success: if let value = response.result.value { print(value) } case .failure(let error):

Sending nested FormData on AJAX

爱⌒轻易说出口 提交于 2019-12-04 02:00:16
I need to send some data using ajax and FormData, because I want to send a file and some other parameters. The way I usually send data is this: $.ajax({ type: 'POST', url: 'some_url', dataType: 'json', processData:false, contentType:false, data:{ Lvl_1-1: 'something', Lvl_1-2: 'something', Lvl_1-3: { Lvl_1-3-1: "something", Lvl_1-3-2: "something", Lvl_1-3-3: "something", }, }, ... }); If I don't use FormData(), I have no problem, but when using FormData(), only the data on Lvl1 is ok, but anything nested is displayed as string like this <b>array</b> <i>(size=3)</i> 'Lvl1-1' <font color='

javascript xhr file upload without jQuery

て烟熏妆下的殇ゞ 提交于 2019-12-03 22:04:35
i have some trouble to make xhr file upload without jquery. (please don't said that use jQuery). if the browser support FormData API and use it, i heard it is possible to upload file(s) also. the matter is i don't know how the attach file into FormData object. and second problem is how to send the FormData via XHR? i mean, look at the code below: var formData = new FormData(); formData.append('somevalue', 'somevalue'); // string formData.append( ???, ??? ); // file var xhr = new XMLHttpRequest(); xhr.setRequestHeader('Content-type', 'multipart/form-data; charset=UTF-8'); xhr.open('post', 'URL