servalproject / serval-dna

The Serval Project's core daemon that implements Distributed Numbering Architecture (DNA), MDP, VoMP, Rhizome, MeshMS, etc.
http://servalproject.org
Other
170 stars 81 forks source link

File insertion via ajax is not working need help #118

Closed iktareen closed 6 years ago

iktareen commented 7 years ago

var data=new FormData(); data.append("manifest",""); data.append("payload",file);

$.ajax
({
  type: "POST",
  url: "http://localhost:4110/restful/rhizome/insert",
  data:data,
  processData: false,
  contentType:'rhizome/manifest; format=text+binarysig',
  headers: {
    "Authorization": "Basic " + btoa(username + ":" + password)
  }, 
  success: function (data){
    console.log(data);
  },
  error:function(data){
    console.log("error"); 
  }
});
lakeman commented 7 years ago

What kind of response are you getting? Can you look at the raw request / response details in your browser's network inspection tools?

We use /restful/rhizome/insert lots in test cases with curl. eg; https://github.com/servalproject/serval-dna/blob/development/tests/rhizomerestful#L569

iktareen commented 7 years ago

if i use content type as above then nothing happens and post request changes to options request but when i set contentType false and use data.append("type",'"rhizome/manifest; format=text+binarysig"'); then it says 415 Unsupported Content-Type in "manifest" form part

iktareen commented 7 years ago

curl command is working on our pc but we can't send file via http.

iktareen commented 7 years ago

these are the parems -----------------------------14236520919255 Content-Disposition: form-data; name="manifest"

-----------------------------14236520919255 Content-Disposition: form-data; name="type"

rhizome/manifest; format=text+binarysig -----------------------------14236520919255 Content-Disposition: form-data; name="payload"

C:/Program Files/nodejs/site/public/chat/5381b44adcd31c8841e0b4ab3013eea08c7afa4b_f3751173cf413033da9676f3ac6086157005059c_m -----------------------------14236520919255--

lakeman commented 7 years ago

The browser may send an OPTIONS request. We have curl based tests for how that is supposed to work. But we don't have automated tests that cover every browser.

I can't really help you if you can't provide the raw data from your request / response. Or detailed output of running your test with our http related debug flags.

quixotique commented 6 years ago

The request parameters shown above are not correctly formed. Others have had difficulty using the RESTful HTTP interface as well. Clearly the Serval DNA documentation needs improving, even though all the clues can be gleaned by trawling through the relevant standards documents.