0
0

More than 1 year has passed since last update.

Firebase Storageから全ての画像ダウンロード

Last updated at Posted at 2022-07-08

該当するフォルダを事前に作成する必要がある

download.js
const admin = require('firebase-admin');
const fs = require('fs');

const serviceAccount = require("path/to/serviceAccountKey.json");

admin.initializeApp({
    credential: admin.credential.cert(serviceAccount),
    storageBucket: "<BUCKET_NAME>.appspot.com"
});

const bucket = admin.storage().bucket();

async function main() {
    const files = await bucket.getFiles();
    files[0].forEach(async (file) => {
        const filePath = `./work/${file.name}`;
        if (!fs.existsSync(filePath)) {
            console.log(filePath);
            await file.download({ destination: filePath });
        }
    });
}

main().then();

gsutilの方が良さそう

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0