How to convert Blob type to File type

When copying and pasting pictures to upload automatically, it is found that the enterprise WeChat browser will recognize the file type as Blob type, so that the backend cannot recognize the file type.
After querying, it is found that converting the Blob file to a File file can solve the problem.

This is a screenshot of the definition of Blob in insert image description here
MDN: This is the parameter required to construct a File type in MDN:
insert image description here
This is my implementation method:

const Blob2ImageFileForWXBrowser = (obj: Blob) => new window.File([obj], `${
      
      (new Date).getTime()}.png` );

Guess you like

Origin blog.csdn.net/xieamy/article/details/110919216