Create read stream after all early return checks

This commit is contained in:
Jackson Harper 2023-01-12 15:48:54 +08:00
parent 444d4a69eb
commit 6f588e2170

View file

@ -195,13 +195,6 @@ const contentHandler = async (
const handleEvent = async (data: StorageEvent) => {
if (shouldHandle(data)) {
console.log('handling csv data', data)
const stream = storage
.bucket(data.bucket)
.file(data.name)
.createReadStream()
const handler = handlerForFile(data.name)
if (!handler) {
console.log('no handler for file:', data.name)
@ -220,6 +213,11 @@ const handleEvent = async (data: StorageEvent) => {
return
}
const stream = storage
.bucket(data.bucket)
.file(data.name)
.createReadStream()
const ctx = {
userId,
countImported: 0,