ファイルのアップロード

Google Page Creator(以下、GPC)のファイルのアップロードをスクリプトでできたら便利じゃね?と思って調べてみる。

2006/6/4 15:23:57

GPCのファイルアップロードのフォームは次のようなコードになっている。

<form action="/upload-file-simple/hiroki1124?authtoken=xxxxx" 
      onsubmit="return false" 
      style="margin-bottom: 0px;" 
      target="tr_post-iframe-tr_1149401474113" 
      accept-charset="utf-8" 
      enctype="multipart/form-data" 
      method="post">
  <input type="file" size="7" name="file" style="-moz-user-select: none;"/>
</form>

これをまねしたファイルをローカルに作ってやる。

<form action="http://pages.google.com/upload-file-simple/hiroki1124?authtoken=xxxxx"
      accept-charset="utf-8" 
      enctype="multipart/form-data" 
      method="post">
  <input type="file" size="7" name="file"/>
  <input type="submit"/>
</form>

ほいで、アップロードに成功。あとは、authtokenの値をなんとかして手に入れるだけ。

2006/6/4 15:58:9

ログインするHTMLを書いてみた。

<form method="post" action="https://www.google.com/accounts/ServiceLoginAuth">
 <input name="Email" />
 <input name="Passwd"/>
 <input type="checkbox" checked="" value="yes" name="PersistentCookie"/>
 <input type="hidden" value="1" name="rmShown"/>
 <input type="submit">
</form>

でも、これをRubyにやらせるにはSSLがいるよなぁ。

続きはまた、そのうちやろう。