curlで遊ぶFlashAir

2015年3月20日

curl (かーる) という,Webアクセスのためのコマンドラインツールがあります.
今回はこのcurlを使って,FlashAir Developersのチュートリアルを再現してみます.
以下,お使いの環境にcurlをインストールし,FlashAirを用意してお楽しみください.

1. コンテンツリストの取得

$ curl "http://flashair/command.cgi?op=100&DIR=/DCIM/100__TSB"
WLANSD_FILELIST
/DCIM/100__TSB,FA000001.JPG,128751,33,17181,18432

$

2. コンテンツのダウンロード

$ curl --get "http://flashair/DCIM/100__TSB/FA000001.JPG" -o FA000001.JPG
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  125k  100  125k    0     0   116k      0  0:00:01  0:00:01 --:--:--  595k

$ ls
FA000001.JPG

$

3. サムネイルの表示

$ curl --get "http://flashair/thumbnail.cgi?/DCIM/100__TSB/FA000001.JPG" -o thumbnail.jpg

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  5163  100  5163    0     0   5368      0 --:--:-- --:--:-- --:--:-- 48707

$ ls
FA000001.JPG  thumbnail.jpg

$

4. コンテンツの自動更新

$ curl --get "http://flashair/command.cgi?op=102"
1
$ curl --get "http://flashair/command.cgi?op=102"
0
$

5. SSIDとパスワードの変更

$ curl --get "http://flashair/config.cgi?MASTERCODE=0123456789AB&APPSSID=myflashair&APPNETWORKKEY=12345678"
SUCCESS
$

6. FlashAirへのアップロード

$ curl --get "http://flashair/upload.cgi?WRITEPROTECT=ON"
SUCCESS
$ curl --get "http://flashair/upload.cgi?FTIME=0x00210000"
SUCCESS
$ curl --get "http://flashair/upload.cgi?UPDIR=/DCIM"
SUCCESS
$ curl --form "file=@FA000001.JPG" "http://flashair/upload.cgi"
<html xmlns="http://www.w3.org/1999/xhtml"><head><META http-equiv="Content-Type" CONTENT="text/html; charset=utf-8"/><h1>Success</h1><br>
<form action=/upload.cgi method=post enctype=multipart/form-data>
<input name=file type=file size=50><br>
<input type=submit value=submit ></form>
</body></html>
$ curl "http://flashair/command.cgi?op=100&DIR=/DCIM"
WLANSD_FILELIST
/DCIM,100__TSB,0,16,17181,18432
/DCIM,FA000001.JPG,128751,32,33,15

$

おしまい.
curlは,FlashAirとの相性抜群ですね!

詳しいことはFlashAir Developersをご覧ください!

Tags

About Author

doi

Leave a Comment

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください

Recent Comments

Social Media