onBuildItemForm in filereader onLoad function #532
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
i am converting selected file to BinaryString using fileReader onload function.
can i call this.uploader.onBuildItemForm in fileReader onload function,.
<input type="file" ng2FileSelect [uploader]="uploader" id="fileUpload" (change) = "handleFileSelect($event)"/>
public uploader:FileUploader = new FileUploader({url:'http://localhost:8080/new',
autoUpload: true,
allowedMimeType: ['image/png', 'image/jpg', 'image/bmp', 'application/pdf'],
maxFileSize: 510241024 // 5 MB
});
handleFileUpload(selectedFile):void {
let fileReader = new FileReader();
fileReader.onload = () => {
this.imageStream = btoa(fileReader.result);
}
fileReader.readAsBinaryString(selectedFile);
fileReader.onloadend = () => {
setTimeout(() => {
this.uploader.onBuildItemForm = (item, form) => {
console.log('..............' + this.imageStream);
form.append("blob", this.imageStream);
};
}, 5000);
}
}
Please Help me.... i am stuck here