Trying to upload both the image file and the pdf file to the Firebase repository, loading the image works fine, and loading the pdf file with a very similar return code
Missed Error: This browser does not seem to support Blobs creation.
NodeJS, ReactJS
Please see below code
// 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") }) }
reactjs uncaught-typeerror firebase firebase-storage
Jimmy J. Lin
source share