I thought I could clone File object in the same way as any other object with: JSON.parse(JSON.stringify(file))
But, JSON.stringify(file)
always evaluates to "{}"
. Is there any workaround besides creating empty object and iterating over all properties of file object and adding them to it?
Also is there any reason why File objects cannot be converted to string? I though they only store information about file on disk, such as name and path, not the file contents.
new File([blob], blob.name, { type: blob.type });
Adding the type is important. The accepted answer missed the type.
new File([file], file.name)
returns copy of file
object
hjfgfg
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With