Reputation: 123
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?
Upvotes: 1
Views: 514
Reputation: 123
Finally I found the solution. It's a webpack issue. Webpack is renaming all classnames, so I used TerserPlugin this way:
const TerserPlugin = require("terser-webpack-plugin");
module.exports = {
// context: __dirname,
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
terserOptions: {
keep_classnames: true,
keep_fnames: true
}
})
]
},
...
Now all class names are not renamed and is working perfectly.
Upvotes: 1