I am trying to send an Excel file from my local machine to our webservice.
In my view, I am using input type "file" to select the file, and then I send that file to this webservice call:
uploadArticles: function (file, filename) {
var fd = new FormData();
fd.append('UPLOADFILE', file);
fd.append('APPNAME', 'MY_APP');
fd.append('PRGNAME', 'UPLOAD_EXCEL');
fd.append('SESSIONID', '12345');
fd.append('UPDATE', 'Y');
fd.append('UPLOADFILENAME', filename);
fd.append('ARGUMENTS', 'SESIONID,UPLOADFILE,UPLOADFILENAME,UPDATE');
$http.post(MAGIC_URL, fd, {
transformRequest: angular.identity,
headers: {'Content-Type': undefined}
}).success(function (response) {
console.log('SUCCESS! ', response);
}).error(function (response) {
console.log('ERROR! ', response);
});
}
We are using uniPaaS to take ARGUMENTS file blob and write it to a directory on our server. It is working properly, however when I try to open the file itself, the blob text is being written inside of the Excel file. It is almost as if the file is not interpreted properly.
Here's an example of what is inside of the Excel file:
data:text/rtf;base64,e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcY29jb2FydGYxNDA0XGNvY29hc3VicnRmNDcwCntcZm9udHRibFxmMFxmc3dpc3NcZmNoYXJzZXQwIEhlbHZldGljYTt9CntcY29sb3J0Ymw7XHJlZDI1NVxncmVlbjI1NVxibHVlMjU1O30KXG1hcmdsMTQ0MFxtYXJncjE0NDBcdmlld3cxMDgwMFx2aWV3aDg0MDBcdmlld2tpbmQwClxwYXJkXHR4NzIwXHR4MTQ0MFx0eDIxNjBcdHgyODgwXHR4MzYwMFx0eDQzMjBcdHg1MDQwXHR4NTc2MFx0eDY0ODBcdHg3MjAwXHR4NzkyMFx0eDg2NDBccGFyZGlybmF0dXJhbFxwYXJ0aWdodGVuZmFjdG9yMAoKXGYwXGZzMjQgXGNmMCB0ZXN0IDEyMzR9
Am I approaching this file upload improperly?
EDIT:
I was able to resolve this. uniPaaS has the ability to transform Base64 to Blobs, but this was not working properly for whatever reason. I was able to convert this Base64 to a Blob using JavaScript, I sent the blob to uniPaaS, and the file was written properly.
For anyone else running into this issue, please see this discussion: Creating a Blob from a base64 string in JavaScript