Is there a way we could set the size property of the File
object. I will be getting the size as number from the api.
This is what I tried,
const file = new File([''], filename , { size: 100 })
This does not seem like working. Can someone help?
Is there a way we could set the size property of the File
object. I will be getting the size as number from the api.
This is what I tried,
const file = new File([''], filename , { size: 100 })
This does not seem like working. Can someone help?
3
Answers
The size is determined by the data in the File object. It isn’t an independent value that you can explicitly set.
Have a look at File documentation
The problem with your code is your array buffer is empty so that you are getting 0 size. Also pass the second parameter as string for the filename.
As you are telling that you want to set the size of the file according to the received size then you have to put the data of that size in that file.
As the third parameter is for type and last modified.