**** Update ****
The reason I thought this wasnt working was because the BroccoliTypeScriptCompiler (Which I wasnt using until RC5 when I rebuilt my application) is recompiling the application every time a new file is uploaded into the public/temp folder. I've tried to prevent this behavior by using the exclude tag on the tsconfig.json file located in my src folder as well as trying to one in my e2e folder, but neither one seems to have any effect on this action.
Can someone please tell me how to stop BroccoliTypeScriptCompiler from recompiling my application any time a new file is added to /public/temp?
**** Original ****
I just finished updating my application from RC4 to RC5. I still have my RC4 application in tact to test with. This app was originally created back in the beta phases of Angular2. The other thing I just completed was rebuilding the application in the new folder structure that seemed to come about with the angular CLI.
After doing this, my xhr upload process to upload files locally no longer works. Its literally the same exact code that still works in the RC4 version. I havent been able to find anything online that could lead me to understand why this is happening.
When I run this in RC5 the result in profile-input.component is null. The xhr.response in upload-file.service has the complete object as expected.
Any help would be great.
profile-input.component.ts
upload() {
console.log('this.createdProfile before upload');
console.log(this.createdProfile);
this.uploadFileService.makeFileRequest("http://localhost:3000/upload", this.createdProfile.profileId, this.filesToUpload)
.then(
(result) => {
console.log('result in prof input action removed is');
console.log(result);
// this.imageUploaded = true;
// this.uploadFile = result.obj.path;
// this.uploadObject = result.obj;
},
(error) => {
console.log('We are in error');
console.error(error);
});
}
upload-file.service.ts
makeFileRequest(url: string, profileId, files: Array<File>) {
const token = localStorage.getItem('token') ? '?token=' + localStorage.getItem('token') : '';
console.log('profileId in upload service is: ');
console.log(profileId);
const profileParam = 'profileId=' + profileId;
return new Promise((resolve, reject) => {
var formData: any = new FormData();
var xhr = new XMLHttpRequest();
for(var i = 0; i < files.length; i++) {
formData.append("uploads[]", files[i], files[i].name);
}
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
console.log('xhr.status is 200');
console.log('xhr.response is');
console.log(xhr.response);
resolve(JSON.parse(xhr.response));
} else {
console.log('xhr.status is NOT 200');
reject(xhr.response);
}
}
};
xhr.open("POST", url+token+'&'+profileParam, true);
xhr.send(formData);
});
}