# LINE notify を使って画像ファイルを定期的に送りたい

**URL:** <https://discourse.nodered.org/t/line-notify/47125>\
**Category:** General\
**Created:** [14 June 2021 07:39 UTC](https://discourse.nodered.org/t/line-notify/47125 "2021-06-14T07:39:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wtaro513](https://avatars.discourse-cdn.com/v4/letter/w/c5a1d2/32.png) [@wtaro513](https://discourse.nodered.org/u/wtaro513)\
**Post date:** [14 June 2021 07:39 UTC](https://discourse.nodered.org/t/line-notify/47125/1 "2021-06-14T07:39:42Z")

</div>

ラズパイにUSBカメラを接続し、１時間毎に撮影した画像データをLINEを使って送りたいと考えています。  
単純にインジェクトノード、momentノード、usbcameraノード、imageノードでラズパイ内には保存できるようになったのですが、LINE notifyノードに接続してもLINEに画像を送れません。  
LINEに通知は来るのですが、日時データのみで画像が添付できません。不可能なのでしょうか？  
LINEがいいのですが、他に画像を送る方法で良いものがあれば教えて頂ければありがたいです。

---

<div class="post-metadata">

**Author:** ![utaani](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/utaani/32/102_2.png) [@utaani](https://discourse.nodered.org/u/utaani)\
**Post date:** [15 June 2021 07:22 UTC](https://discourse.nodered.org/t/line-notify/47125/2 "2021-06-15T07:22:53Z")

</div>

(The English version will be attached at the end.)

LINE notifyをサポートする2つのカスタムノード  
[https://flows.nodered.org/search?term=line-notify](https://flows.nodered.org/search?term=line-notify)  
は、どちらも、imageFileパラメータを使って直接画像をLINEに送れないです。  
文面から、wtaro513さんは [node-red-contrib-line-notify](https://flows.nodered.org/node/node-red-contrib-line-notify) をお使いと推測します。このカスタムノードは、通知に含めたい画像は公開された画像URLで指定しますので、あらかじめRaspberry Piで取得した画像を、LINEがアクセスできるインターネット上に公開する必要があります。

1度のPOSTでメッセージデータと画像データを送るためには、 [LINE Notify API Document](https://notify-bot.line.me/doc/ja/)に記述がある「imageFile」パラメータを使って、POST時に"content-type": "multipart/form-data"形式でmsg.payloadを作ってhttp requestする必要があります。

* * *

Two custom nodes that support LINE notify  
[https://flows.nodered.org/search?term=line-notify](https://flows.nodered.org/search?term=line-notify)  
Neither can send images directly to LINE using the imageFile parameter.

From your post, I guess you are using [node-red-contrib-line-notify] ([node-red-contrib-line-notify (node) - Node-RED](https://flows.nodered.org/node/node-red-contrib-line-notify)). In this custom node, the image you want to include in the notification is specified by the published image URL, so you need to publish the image acquired with Raspberry Pi in advance on the Internet that LINE can access.

In order to send message data and image data in one POST, use the "imageFile" parameter described in [LINE Notify API Document][LINE Notify](https://notify-bot.line.me/doc/en/) and use the "content-type": "multipart / form-data" format at the time of POST. You need to create msg.payload in and make an http request.

---

<div class="post-metadata">

**Author:** ![wtaro513](https://avatars.discourse-cdn.com/v4/letter/w/c5a1d2/32.png) [@wtaro513](https://discourse.nodered.org/u/wtaro513)\
**Post date:** [17 June 2021 00:28 UTC](https://discourse.nodered.org/t/line-notify/47125/3 "2021-06-17T00:28:43Z")

</div>

ご解答ありがとうございます。ただ私でチャレンジするにはハードルが高い内容のようです。  
フローで例を作成して頂けないでしょうか。

---

<div class="post-metadata">

**Author:** ![utaani](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/utaani/32/102_2.png) [@utaani](https://discourse.nodered.org/u/utaani)\
**Post date:** [17 June 2021 06:56 UTC](https://discourse.nodered.org/t/line-notify/47125/4 "2021-06-17T06:56:20Z")

</div>

とりあえず添付のFlowで、/home/pi/lineimage.png に置いたPNG画像ファイルを含んだNotifyを送信できました。  
（Functionノードの中のTOKENを、ご自身のLine Notifyトークン文字列に置き換えてください）  
（これ以上はサポートできません...）

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/e/9e6adf9af3f2c26d8480234db5f7ffb3ea91f28d.png)

```auto
[{"id":"f8520b99.0d75c","type":"inject","z":"fe7d9b9b.368ed8","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":220,"wires":[["82e67ef7.8ae8d8"]]},{"id":"ef6db0ec.8eb1c","type":"http request","z":"fe7d9b9b.368ed8","name":"LineNotifyに送信","method":"POST","ret":"txt","paytoqs":false,"url":"https://notify-api.line.me/api/notify","tls":"7ec9ecab.9bc5dc","persist":false,"proxy":"","authType":"","x":510,"y":400,"wires":[["fe2dc22e.d3047","92823616.94c0f8","d97f1b37.307ce8","71063f8b.7cd98"]]},{"id":"82e67ef7.8ae8d8","type":"file in","z":"fe7d9b9b.368ed8","name":"送信画像(PNGファイル指定)","filename":"/home/pi/lineimage.png","format":"","chunk":false,"sendError":false,"encoding":"none","x":200,"y":280,"wires":[["3b5832d2.1d6756"]]},{"id":"3b5832d2.1d6756","type":"function","z":"fe7d9b9b.368ed8","name":"メッセージ作成（TOKENを自分のトークンに置換）","func":"var img = msg.payload;\n\nmsg.payload = {\n \"message\": \"テキストメッセージ\",\n \"imageFile\": {\n \"value\":img,\n \"options\": {\n \"filename\":\"lineimage.png\",\n \"contentType\":\"image/png\"\n }\n }\n};\n\nmsg.headers = {\n \"authorization\": \"Bearer TOKEN\",\n \"content-type\": \"multipart/form-data\"\n};\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":340,"y":340,"wires":[["ef6db0ec.8eb1c"]]},{"id":"fe2dc22e.d3047","type":"debug","z":"fe7d9b9b.368ed8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":850,"y":260,"wires":[]},{"id":"92823616.94c0f8","type":"debug","z":"fe7d9b9b.368ed8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"headers","targetType":"msg","x":850,"y":300,"wires":[]},{"id":"d97f1b37.307ce8","type":"debug","z":"fe7d9b9b.368ed8","name":"残りNotify送信回数","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"headers[\"x-ratelimit-remaining\"]","targetType":"msg","x":830,"y":360,"wires":[]},{"id":"71063f8b.7cd98","type":"debug","z":"fe7d9b9b.368ed8","name":"残りイメージ送信回数","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"headers[\"x-ratelimit-imageremaining\"]","targetType":"msg","x":820,"y":400,"wires":[]},{"id":"7ec9ecab.9bc5dc","type":"tls-config","name":"","cert":"","key":"","ca":"","certname":"","keyname":"","caname":"","servername":"","verifyservercert":true}]

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [16 August 2021 06:56 UTC](https://discourse.nodered.org/t/line-notify/47125/5 "2021-08-16T06:56:32Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
