#firebase functionsのemulatorにstorageが追加されたので試してみた。
今までfirebaseのemulatorにはfirestoreやAuthなどはあったがstorageは無かった。
どうやら今朝追加されたらしいので早速試してみた。
$ npm install -g firebase-tools
アップデートがまだな場合はしておく
$ firebase init emulators
↓
(*) Functions Emulator
(*) Firestore Emulator
( ) Database Emulator
(*) Hosting Emulator
(*) Pub/Sub Emulator
(*) Storage Emulator```
通常通り起動してみると一番下にStorageが追加されてる。

通常通り進めて行く
```? Which port do you want to use for the auth emulator? 9099
? Which port do you want to use for the functions emulator? 5001
? Which port do you want to use for the firestore emulator? 8080
? Which port do you want to use for the hosting emulator? 5000
? Which port do you want to use for the pubsub emulator? 8085
? Which port do you want to use for the storage emulator? (9199)
? Would you like to enable the Emulator UI? Yes
? Which port do you want to use for the Emulator UI (leave empty to use any available port)?
? Would you like to download the emulators now? Yes```
↓
そのまま進めてみたらエラーが出た。

```Error: Cannot start the Storage emulator without rules file specified in firebase.json: run 'firebase init' and set up your Storage configuration```
Firestoreの場合はセキュリティルールのファイルが無くても動いたがStorageの場合は、どうやらセキュリティルールがいるらしいので、firebase.jsonの中にセキュリティルールに関する記述を追加。
}```"firestore": {
"rules": "firestore.rules"
},
"storage": {
"rules": "storage.rules"
},
}```
更にstorage.rulesを作ってルートディレクトリに追加する。
storage.rules内の記述はとりあえず全てfalseにした。
```rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read, write: if false;
}
}
}```
再び進めて行く
```$ firebase init emulators```
↓
```Firebase initialization complete!```
今度は通常通りFirebase initialization complete!と出るので、
```$ firebase emulators:start```
emulatorを起動する。

firebase emulatorにstorageが追加されてるので、storageトリガーのfunctionsをテストする際など容易になると思う。
因みにJavaが無いと一部動かないので、
```Firestore Emulator has exited because java is not installed```
と出る場合は、
https://www.java.com/ja/download/manual.jsp
から「Windows オンライン」をクリック。(ダウンロードが始まる。)
ダウンロードされた「jre-8u271-windows-i586-iftw.exe」を実行。
「Windows セキュリティの重要な警告」が表示されるので、
「アクセスを許可する」をクリック。