1. Google Developer Consoleで APIの有効化・サービスアカウント作成し、JSONファイルをダウンロード
1-1. Google Developer Consoleにアクセスする
1-3. 新しいプロジェクトをクリック
1-5. 作成したプロジェクトを選択し、Google Drive APIを有効にする
1-7. サービスアカウントの編集画面から鍵を作成しJSONファイルをダウンロードする
2. Google Driveでフォルダを作成し、フォルダを先ほど作成したサービスアカウントに共有する
3.作成したフォルダのURLからフォルダIDを取得
4. Node-Redのパレットから「node-red-contrib-google」ノードをインストール
5. フローを読み込み、各ノードブロックのプロパティを設定する
[{"id":"37fe8973.9b3846","type":"change","z":"d7300f51.c03af","name":"set parameters","rules":[{"t":"set","p":"folderid","pt":"msg","to":"","tot":"str"},{"t":"set","p":"filename","pt":"msg","to":"test.jpg","tot":"str"},{"t":"set","p":"mimeType","pt":"msg","to":"image/jpg","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"{\t \"resource\": {\t \"name\": filename,\t \"parents\": [\t folderid\t ]\t },\t \"media\": {\t \"mimeType\": mimeType,\t \"body\": payload\t },\t \"fields\": \"id\"\t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":140,"wires":[["d862bfac.a32a7"]]},{"id":"39a1f760.f13da8","type":"debug","z":"d7300f51.c03af","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":630,"y":140,"wires":[]},{"id":"d862bfac.a32a7","type":"google","z":"d7300f51.c03af","name":"","google":"be4a5517.9547d8","api":"drive:v3","operation":"files.create","x":470,"y":140,"wires":[["39a1f760.f13da8"]]},{"id":"caf7c056.9ef8d","type":"file in","z":"d7300f51.c03af","name":"","filename":"","format":"","chunk":false,"sendError":false,"encoding":"none","x":470,"y":80,"wires":[["37fe8973.9b3846"]]},{"id":"7d1550df.83376","type":"change","z":"d7300f51.c03af","name":"","rules":[{"t":"set","p":"filename","pt":"msg","to":"/home/pi/Pictures/test/test.jpg","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":310,"y":80,"wires":[["caf7c056.9ef8d"]]},{"id":"e8c966be.6e9248","type":"inject","z":"d7300f51.c03af","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":80,"wires":[["7d1550df.83376"]]},{"id":"be4a5517.9547d8","type":"google-conn","z":"","name":"Google","key":"{}\n","scopes":"https://www.googleapis.com/auth/drive\nhttps://www.googleapis.com/auth/drive.appdata\nhttps://www.googleapis.com/auth/drive.file\nhttps://www.googleapis.com/auth/drive.metadata\nhttps://www.googleapis.com/auth/drive.metadata.readonly\nhttps://www.googleapis.com/auth/drive.photos.readonly\nhttps://www.googleapis.com/auth/drive.readonly\nhttps://www.googleapis.com/auth/drive.scripts"}]
googleノードブロック:JSON Keyを手順1-7で取得したJSONファイルの内容で設定
「set parameters」ブロック:「folderid」に手順3で取得したフォルダIDを設定
「set msg.filename」ブロック:送信対象の画像ファイルのパスを設定