Open ivange94 opened 5 years ago
Has this problem been solved?
let metaInfo = {
name: "metainfo",
id: "123",
color: ["red", "blue"],
}
const formData = new FormData();
Object.keys(metaInfo).forEach(key => {
formData.append(key, metaInfo[key]);
})
this.$http.post('http://192.168.43.1:5050/test/', formData).then( (response) => console.log(response), (error) => console.log(error) );
* AndroidAsync Server End : the `post` method which listen to special path regex should contain some code below:
https://github.com/koush/AndroidAsync/blob/d0042f720c557a27a963553dae1e0ea58d00400f/AndroidAsync/test/src/com/koushikdutta/async/test/MultipartTests.java#L48-L73
### NOTE
* Front End:
* please **DO NOT** use `axios`, `URLSearchParams` or `xmlhttprequest` to post info;
* if the object appended in formData is complex structure, you should append each key in the formData but do not just append the whole object in it, which cause `Server Get Field is [Object Object]` problem;
* Server End:
* maybe you should set CORS with `response.getHeaders().set("Access-Control-Allow-Origin", "*");`
I have a simple server in android that I'm trying to access from my PC. I have setup the endpoints like this
I placed a breakpoint inside post request handler and the formData of the request body is always null. I've been unable to access the file submitted in this POST request. I made my request using curl with the command below
curl -F 'filename=@/Users/l4rry/test/names.txt' http://192.168.1.178:8080/scan
I'm I doing something wrong? How can I get multipart POST to work?