I'm loading data from a CSV located in Cloud Storage from a simple NodeJS script without problems, using RunJS:
const bucketName = 'xxxx';
const filename = 'datasets/soa/soa.csv';
const datasetId = 'lbl';
const tableId = 'soa';
const metadata = { ... }
const [job] = await bigqueryClient
.dataset(datasetId)
.table(tableId)
.load(storage.bucket(bucketName).file(filename), metadata);
console.log(`Job ${job.id} completed.`);
Everything works fine. But when I implement the same code in my backend project using Typescript, it always raises the error:
Source must be a File object.
I tried everything I know. This is my Typescript code:
import { BigQuery } from "@google-cloud/bigquery";
import { Storage } from "@google-cloud/storage";
loadData() {
const bucketName = 'xxxx';
const filename = 'datasets/soa/soa.csv';
const datasetId = 'lbl';
const tableId = 'soa';
const metadata = { ... }
return this.client
.dataset(datasetId)
.table(tableId)
.load(this.storage.bucket(bucketName).file(filename), metadata);
}
Any ideas?