emolog

脳内メモです。

2020-04-26から1日間の記事一覧

Cloud Functions for Firebaseで環境変数を設定する

firebase.google.com 環境変数の設定 firebase functions:config:set service_name.api_key="hogehoeg" 環境変数の削除 firebase functions:config:unset service_name コンソール内で設定した環境変数の確認 firebase functions:config:get コード内で取得(…

axiosで取得した画像をbase64エンコードしたい人生だった

うまくいかなったのでメモ 結論 responseType: 'arraybuffer' の指定が必要 axios.get(url, { responseType: 'arraybuffer' }) .then(response => Buffer.from(response.data, 'binary').toString('base64')) 参考 github.com

base64エンコードついて調べたのでメモ

外部APIを叩く時に画像をbase64エンコードしてpostする必要があったのでメモです。 mac base64 -i input.jpg -o output.txt javascript const fs = require('fs'); const imageFile = fs.readFileSync('/path/to/file'); const encodedImage = Buffer.from(i…