const admin = require("firebase-admin");
const uuid = require('uuid-v4');
const serviceAccount = require("./serviceAccountKey.json");
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
storageBucket: "fire-practice-436e4.appspot.com"
});
const bucket = admin.storage().bucket();
const filename = "./miao.png"
async function uploadFile() {
const metadata = {
metadata: {
firebaseStorageDownloadTokens: uuid()
},
contentType: 'image/png',
cacheControl: 'public, max-age=31536000',
};
await bucket.upload(filename, {
gzip: true,
metadata: metadata,
});
console.log(`${filename} uploaded.`);
}
uploadFile().catch(console.error);