One of the challenges I'm facing is dealing with a file upload using antdUpload
The HTML code snippet for the uploader is as follows:
<Upload
beforeUpload={((file: RcFile, fileList: RcFile[]): boolean => {this.requestUpload(file, (fileList.length || 0 )); return false;})}
></Upload>
The function that handles the upload process is shown below:
requestUpload(file: RcFile, nbFile: number): void {
const reader = new FileReader();
reader.onload = (): void => {
FileHelper.uploadFile({
filename: file.name,
filepath: `${this.props.datastoreId}/${this.props.itemId}/${this.props.fieldId}/${file.name}`,
file: reader.result,
field_id: this.props.fieldId,
item_id: this.props.itemId || '',
d_id: this.props.datastoreId || '',
p_id: this.props.projectId || '',
display_order: nbFile
}).subscribe()
};
reader.readAsArrayBuffer(file);
}
My main challenge lies in obtaining raw binary data from the uploaded file. My API specifically requires raw binary data and nothing else. Unfortunately, most solutions online suggest methods like using base64 encoding, which doesn't suit my requirements. How can I convert `reader.result` into pure binary raw data?
I have researched various stack overflow threads without success. They provide alternative approaches but don't address how to achieve raw binary data when no other options are viable.
If you have any insights or suggestions on how I can accomplish this task, please share your thoughts. Thank you!