0
const {Storage} = require('@google-cloud/storage');
const fs = require('fs');
const { createReadStream } = require('original-fs');
const util = require("util");
const Multer = require("multer");
const maxSize = 2 * 1024 * 1024;

//const bucketName = 'trialE.json';
const bucketName = 'gcloudconnection.json'
const GOOGLE_CLOUD_PROJECT_ID = 'xxxxx';

var element = document.getElementById("log-in")

element.onclick = async function onclick(){
const gc =new Storage({
    projectId : GOOGLE_CLOUD_PROJECT_ID,
    keyFilename : bucketName
})

const Bucket= gc.bucket('lawflow');
const file = Bucket.file('testtrial');
//-
fs.createReadStream('/path/to/file')
  .pipe(file.createWriteStream())
  .on('error', function(err) {
    console.log(err)
  })
  .on('finish', function() {
    console.log("DONE");
  });

}

Above is the code from the official google docs, however, when I try running this it throws me an error saying: enter image description here

TypeError: Failed to execute 'fetch' on 'Window': Failed to read the 'signal' property from 'RequestInit': Failed to convert value to 'AbortSignal'.
John Hanley
  • 74,467
  • 6
  • 95
  • 159
ezmzi
  • 1
  • The error image shows the error is happening on line 34 of upload-to-bucket.js. The snippet you showed has less than 31 lines - in your file what is at line 34? – David Sep 29 '22 at 15:53
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Sep 29 '22 at 17:27
  • @David line 34 is just the console.log(error) thats what its pointing to – ezmzi Sep 29 '22 at 19:20

0 Answers0