将 PDF 上传到 Firebase 存储 - 未捕获错误:此浏览器似乎不支持创建 Blob



尝试将图像文件和PDF文件同时上传到firebase存储,图像上传完美地工作,而PDF文件上传具有非常相似的代码返回

未接收错误:此浏览器似乎不支持创建斑点。

nodejs,reactjs

请参阅下面有关代码

// post resume to firebase
function PostResumeToFirebase(id, resume){
  console.log("inside PostResumeToFirebase -------")
  resume.resume_files.forEach((data) => {
    console.log("file inside post resume", data)
    const file = data
    var storageRef = firebase.storage().ref()
    // Upload file and metadata to the object
    const uploadTask = storageRef.child('applicants/resume/' + file.name).put(file);
    // Listen to state changes, errors, and completion of the upload.
    uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED,
      function(snapshot) {
        // Get task progress, inlcuding number of bytes uploaded and the total number of bytes to be uploaded
        var progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
        console.log('Upload is ' + progress + '% done');
        switch (snapshot.state) {
          case firebase.storage.TaskEvent.PAUSED: // or 'paused'
            console.log('Upload is paused');
            break;
          case firebase.storage.TaskState.RUNNING: // or 'running'
            console.log("Upload is running");
            break;
        }
      }, function(error){
        switch (error.code) {
          case 'storage/unauthorized':
            // User doesn't have permission to access the object
            console.log("storage/unauthorized", error)
            break;
          case 'storage/canceled':
            // User canceled the upload
            console.log("storage/canceled", error)
            break;
          case 'storage/unknown':
            // Unknown error occurred, inspect error.serverResponse
            console.log("storage/unknown", error)
            break;
        }
      }, function(){
        // Upload completed successfully, now we can get the download URL
        var downloadURL = uploadTask.snapshot.downloadURL;
        console.log("link to image", downloadURL)
        let resumeData = {
          user_id: id,
          resume_pdf: downloadURL
        }
      // PostPdf(resumeData)
    })
  })

}
function PostPdf(resumeData) {
  console.log("line 937", resumeData)
  $.post('https://atlas-cv-database.herokuapp.com/api/applicants/upload_pdf', resumeData)
    .done((data) => {
      console.log("yay!!! resume posted ---", data)
    })
    .error((error) => {
      console.log("noooooooooooooo")
    })
}

我在过去24小时内遇到了相同的问题,但是在离子V2/Angular 2/Typescript中。

this.dbsref = firebase.storage().ref();
// ... other code ...
this.dbsref.child(picPreviewName).put(byteArray).then(() => {
  console.log("Success!");
});

Uncaught Error: This browser doesn't seem to support creating Blobs

我什至无法上传图像。如果找到分辨率,我将一定要在此处更新。

update!是的,我找到了问题并修复了问题。node_modules/firebase/中有三个文件,它们是firebase-storage.jsfirebase.jsstorage.js。它们被缩小了JavaScript。在所有这些中,搜索n(l.Blob)并将其替换为n(Blob)。由于某种原因,l对象没有BLOB属性。无论如何,Blob都是全局范围,因此它可以在那里检查。这是一个肮脏的hack,但似乎是一个firebase错误。

我在firebase@3.6.2上遇到了同样的问题,我已经降级到firebase@3.5.3,现在一切都很好。

就像我上方的赫雷诺一样,我在firebase@3.6.2上也遇到了同样的问题我已经升级到firebase@3.6.4,我无法再复制错误。

相关内容

  • 没有找到相关文章

最新更新