Base64 编码的字符串转换为 Blob 对象方法

const blob = function (data: string, mime: string) {
  data = data.split(',')[1];
  data = window.atob(data);
  let ia = new Uint8Array(data.length);
  for (var i = 0; i < data.length; i++) {
    ia[i] = data.charCodeAt(i);
  };
  return new Blob([ia], {
    type: mime
  });
};
posted @ 2023-04-25 16:15  摸鱼的云小逸  阅读(439)  评论(0编辑  收藏  举报