I have a function
async function create_blob(image) {
const blob = new Blob([image])
return await blob.text()
}
And I want it to return a string. When I try to use this data blob_hidden_input.value = create_blob(file_object) blob_hidden_value.value is "[Promise object]". So how to convert promise to string without black magic?
imageis a DOMString, and you get back the exact same output as the input, either it's some binary data (from an ArrayBuffer) and here, either it represents an UTF8 text, in which case a TextDecoder is far preferable to do the same, either it's some other data in which case you'll break it by reading it as UTF8. So the only usecase would be ifimagewas a Blob representing an UTF8 encoded text file, but in that case, no need to wrap it into a new Blob.