Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save WoolDoughnut310/cd8bb6a9b6c0a29bd11a815add5a8438 to your computer and use it in GitHub Desktop.
Save WoolDoughnut310/cd8bb6a9b6c0a29bd11a815add5a8438 to your computer and use it in GitHub Desktop.
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