Hi, thank you.
I am having an issue in Typescript where the uploadFilesRequest overload is not being invoked. My onCreated function is being invoked though.
onCreated() {
(Uploader.prototype as any).uploadFilesRequest = function (selectedFiles: any, i: any, custom: any) {
var _this = this;
var cloneFiles: any = [];
var chunkEnabled = this.checkChunkUpload();
var ajax = new Ajax(this.asyncSettings.saveUrl, 'POST', true, undefined);
ajax.emitError = false;
var getFileData;
/* istanbul ignore next */
if (this.isServerBlazor) {
getFileData = selectedFiles.slice(0);
cloneFiles.push(getFileData[i].rawFile);
}
var eventArgs = {
fileData: this.isServerBlazor ? getFileData[i] : selectedFiles[i],
customFormData: [],
cancel: false,
};
var formData = new FormData();
ajax.beforeSend = function (e: any) {
(eventArgs as any).currentRequest = ajax.httpRequest;
/* istanbul ignore next */
if (isBlazor()) {
eventArgs.fileData.rawFile = !chunkEnabled
? _this.base64String[i]
: eventArgs.fileData.rawFile;
if (_this.currentRequestHeader) {
_this.updateCustomheader(
ajax.httpRequest,
_this.currentRequestHeader
);
}
if (_this.customFormDatas) {
_this.updateFormData(formData, _this.customFormDatas);
}
}
};
if (selectedFiles[i].statusCode === '1') {
_this.trigger('uploading', eventArgs, function (eventArgs: any) {
/* istanbul ignore next */
if (_this.isServerBlazor && !chunkEnabled) {
selectedFiles[i].rawFile = eventArgs.fileData.rawFile =
cloneFiles[i];
}
if (eventArgs.cancel) {
_this.eventCancelByArgs({}, eventArgs, selectedFiles[i]);
}
_this.updateFormData(formData, eventArgs.customFormData);
});
var name_5 = this.element.getAttribute('name');
formData.append(
name_5,
selectedFiles[i].rawFile,
selectedFiles[i].name
);
if (
chunkEnabled &&
selectedFiles[i].size > this.asyncSettings.chunkSize
) {
this.chunkUpload(selectedFiles[i], custom, i);
} else {
ajax.onLoad = function (e) {
if (eventArgs.cancel && _this.isServerBlazor) {
return {};
} else {
_this.uploadComplete(e, selectedFiles[i], custom);
return {};
}
};
ajax.onUploadProgress = function (e: any) {
if (eventArgs.cancel && _this.isServerBlazor) {
return {};
} else {
_this.uploadInProgress(e, selectedFiles[i], custom, ajax);
return {};
}
};
/* istanbul ignore next */
ajax.onError = function (e: any) {
_this.uploadFailed(e, selectedFiles[i]);
return {};
};
ajax.send(formData);
}
}
};
}
componentDidMount() {
setTimeout(() => {
this.rendereComplete();
});
}
rendereComplete() {
//this.uploadObj.dropArea = this.dropContainerEle;
this.uploadObj.element.setAttribute('name', 'file');
this.uploadObj.dataBind();
}
public render(): JSX.Element {
return (
<div id='dropArea' onClick={this.dropAreaClick = this.dropAreaClick.bind(this)} ref={dropEle => { this.dropAreaRef = dropEle! }}>
<UploaderComponent id='file'
ref={upload => { this.uploadObj = upload! }}
type={"file"}
asyncSettings={this.path}
uploading={this.onUploading = this.onUploading.bind(this)}
progress={this.onFileUpload = this.onFileUpload.bind(this)}
selected={this.onSelect = this.onSelect.bind(this)}
success={this.onuploadSuccess = this.onuploadSuccess.bind(this)}
failure={this.onuploadFailed = this.onuploadFailed.bind(this)}
template={this.uploaderTemplate = this.uploaderTemplate.bind(this)}
created={this.onCreated.bind(this)} />
</div>);