Created
February 15, 2023 09:23
-
-
Save WoolDoughnut310/cd8bb6a9b6c0a29bd11a815add5a8438 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Storage } from "@google-cloud/storage"; | |
const storage = new Storage({ | |
keyFilename: "KEY_FILENAME.json", | |
}); | |
const bucket = storage.bucket(process.env.GCS_BUCKET as string); | |
export const createWriteStream = (filename: string, contentType?: string) => { | |
const ref = bucket.file(filename); | |
const stream = ref.createWriteStream({ | |
gzip: true, | |
contentType: contentType, | |
}); | |
return stream; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment