English 中文(简体)
类型:不适用
原标题:TypeError: Error URL.createObjectURL() not a function
  • 时间:2021-06-25 22:43:57
  •  标签:
  • manifest

我正试图创造一套可下载内部文本的档案。 我曾看到,需要创建一部南盟,以便通过这个论坛。

chrome.downloads.downloads ({ url: url, filename: fileName, ConflictAction: overwrite , SaveAs: false });

然而,当我尝试使用URL.createUrlObject(URL)时,我发现有一类错误。

var blob = new Blob([textFile], {type: application/octet-binary }); var url = URL.createObjectURL(blob);

我正在使用明显的语言。

问题回答

    chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
  if (request.type === "saveCSV") {
    // for utf8 bom 
    const data =  uFEFF  + request.data;
    const blob = new Blob([data], { type: "text/csv;charset=utf-8" });

    // use BlobReader object to read Blob data
    const reader = new FileReader();
    reader.onload = () => {
      const buffer = reader.result;
      const blobUrl = `data:${blob.type};base64,${btoa(new Uint8Array(buffer).reduce((data, byte) => data + String.fromCharCode(byte),   ))}`;
      chrome.downloads.download({
        url: blobUrl,
        filename: request.filename,
        saveAs: true,
        conflictAction: "uniquify"
      }, () => {
        sendResponse({ success: true });
      });
    };
    reader.readAsArrayBuffer(blob);
    return true;
  }
});

希望这将有助于其他人。

 const binary = atob(codigoBase64);

        const blob = new Blob([binary], { type: "application/pdf" });
        
        const dataURL = `data:${blob.type};base64,${btoa(binary)}`;

        chrome.downloads.download({
            url: dataURL,
            filename: `${nombreArchivo}`,
            saveAs: true, 
        });




相关问题
Class-path in manifest not read when running jar in Unix

I have a client application that needs to run on Unix. It works fine in Windows but i get a NoClassDefFound exception in unix. Here s my manifest file: Manifest-Version: 1.0 Ant-Version: Apache Ant ...

How to add manifest to a .NET DLL?

I have a c# class library project that uses a COM dll registered on the system. I now want to deploy the COM dll as a side-by-side assembly, so I don t have to register it, or interfere with other ...

C# compiler options - embedding manifest file

I have found that it is possible to embedd manifest file (added to resources) with Compiler option /win32manifest. I am trying to find compiler options in VS express but I cannot see it. Could you ...

VSTO remove file without resigning the manifest

I have a file added to my vsto project and I want to remove this file after publishing the project. This is because the file should only be avaliable for some customers, for others we want to remove ...

热门标签