BlobUrl 转 File

186 阅读1分钟

记录一下自己工作中用到的功能

     import axios from 'axios'
     const BLOB_URL:string = 'xxxxxx'
     axios
         .get({
             BLOB_URL,
             {
                 responseType: 'blob'
             }
         })
         .then((res: object) => {
             const file = new File([res.data], 'xxxx.jpg')
             const formData = new FormData()
             formData.append('file', file)
             // your upload action
             // ......
             // ......
         })