Skip to content

Instantly share code, notes, and snippets.

@ogawa0071
Created May 18, 2020 15:31
Show Gist options
  • Select an option

  • Save ogawa0071/efcc08e56021f99806702437030b9554 to your computer and use it in GitHub Desktop.

Select an option

Save ogawa0071/efcc08e56021f99806702437030b9554 to your computer and use it in GitHub Desktop.
List all Google Cloud Storage files.
import fs from "fs";
import { Storage } from "@google-cloud/storage";
const storage = new Storage();
(async () => {
const files = await storage
.bucket("")
.getFilesStream();
for await (const file of files) {
const fileName = file.name;
// console.log(fileName);
await fs.promises.appendFile("files.txt", `${fileName}\n`);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment