In response to Alexander Taborda’s answer ... The first and second parameters of Blob.slice () are the start and end bytes of the original blob, which should form a new blob. Saying:
var blob = file.slice(0,-1);
you do not say “copy to end of file” (this is what I consider your goal), you say “copy the entire block except the last byte”.
As @carestad says
var blob = file.slice(0, file.size);
and then creating a new File () object should create an exact copy with the new name.
Please note that with png a file is considered invalid without a trailing byte.
From: https://developer.mozilla.org/en-US/docs/Web/API/Blob/slice
source share