I think that if you want to have the function of downloading files, and then show the user a preview of the file they selected on their PC and .readAsDataURL() , then use .readAsDataURL() .
If you want to manipulate a text file, use .readAsText()
If you want to manipulate something like an image (for example, convert JPEG to PNG), then use .readAsArrayBuffer() .
There is a fourth method, .readAsBinaryString , but Mozilla's documentation suggests using .readAsArrayBuffer() instead.
source share