Вот моя недавняя попытка кода:
Код: Выделить всё
const handleFilesCallback = async (result) => {
const fileBase64String = result.value.content; // get Base64 encoded file
const byteCharacters = atob(fileBase64String); // convert to byte string
let ia = new Uint8Array(byteCharacters.length); // build Uint8Array
for (let i = 0; i < byteCharacters.length; i++) {
ia[i] = byteCharacters.charCodeAt(i);
}
const binaryString = new Blob(ia, { type: "" }); //create Blob
sendFile(binaryString);
};
Код: Выделить всё
const sendFile = async (file) => {
const response = await fetch(
"javaApiUrl",
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
yourFile: file,
}),
}
).catch((error) => {
console.log("error:", error);
});
const responseJSON = await response.json();
return responseJSON;
};
Подробнее здесь: https://stackoverflow.com/questions/786 ... point-that