I'm trying to send some form-data files to my backend, and I have this issue which consists on the browser (or server, or whatever) keeps ignoring the boundary I have defined and changing on my request payload to some WebKitFormBoundary random generated boundary.
This is what I have defined on my request
.factory('FilesPaymentsImportationsUploadResource', function ($resource, PAYMENTS_API_URL) {
return $resource(PAYMENTS_API_URL + '/v1/payment-files/upload/', { id: "@id" }, {
save: {
method: "POST",
transformRequest: angular.identity,
headers: { 'Content-Type': 'multipart/form-data; boundary=----border----',
'Accept': 'application/json'
}
}
});
})
So, I expected that on my RequestPayload to look likes this:
----border---- Content-Disposition: form-data; name="file_content"; filename="text.txt" Content-Type: text/plain
----border---- Content-Disposition: form-data; name="from_user"
test1
----border---- Content-Disposition: form-data; name="to_user"
test2
----border----
But instead I have
------WebKitFormBoundary7GOXLp9hM5A0TLgS Content-Disposition: form-data; name="file_content"; filename="text.txt" Content-Type: text/plain
------WebKitFormBoundary7GOXLp9hM5A0TLgS Content-Disposition: form-data; name="from_user"
Bonina2 ------WebKitFormBoundary7GOXLp9hM5A0TLgS Content-Disposition: form-data; name="to_user"
Caioteste ------WebKitFormBoundary7GOXLp9hM5A0TLgS--
My Request Header seems to be right, as I expected, I send:
Content-Type:multipart/form-data; boundary=----border----
But it causes me trouble since I define one value to boundary and the form-data has another, which causes the server to lost the form and says I'm sending an empty form-data.