Open xevenheaven opened 9 years ago
@xevenheaven Did you find a solution?
@nass600, I couldn't post with multipart/mixed
so I went by modifying the formData
and sending Content-Type: undefined
in the end:
// Create FormData to send in the request
var formData = new FormData();
// Create Blob for the first part (application/json)
var fileMetaBlob = new Blob(
[angular.toJson(fileMeta)],
{type: 'application/json'}
);
// Create Blob for the second part (application/octet-stream)
var fileBlob = new Blob(
[fileStream],
{type: 'application/octet-stream'}
);
// Append both parts
formData.append('fileInfo', fileMetaBlob);
formData.append('fileData', fileBlob, fileMeta.fileName);
// Restangular Custom POST
return Restangular
.one(url)
.withHttpConfig({
transformRequest: angular.identity,
timeout: 0 // Avoid global setting's timeout on upload
})
.customPOST(formData, undefined, undefined, {
'Content-Type': undefined
});
Not sure if it helps, but sure do hope it does!
This helped me. Thanks @xevenheaven
I'm trying to upload a file in two parts. Here's the
FormData
I've created:I've tried uploading using
$http
and server returns status 200.However, when I tried with
Restangular
, server returns status 400.Can anybody shed light on this? Any help is greatly appreciated! Thanks! :blush: