Looking to implement a feature where I can easily upload files from Angular to PostgreSQL using a Golang API.
In my Angular component, I need to convert my file
into a uInt8Array
. I have managed to convert the array, but it seems to be encapsulated in something unfamiliar (see image for reference).
How can I extract the uInt8Array and assign it to a variable like let x : uInt8Array = y;
?
Here's what I have tried so far:
x.component.html
<input (change)="onFileSelected($event)" type="file" id="fileUpload">
x.component.ts
onFileSelected(event) {
console.log("called");
const file: File = event.target.files[0];
if (file) {
console.log(file.arrayBuffer());
console.log("call finished");
}
}
The output was similar to the previous screenshot.