高度なカスタマイズ > Info*Engine ユーザーガイド > Info*Engine データ管理 > BLOB のアップロードおよびダウンロード > BLOB のダウンロードのためのフォーム変数の使用方法
  
BLOB のダウンロードのためのフォーム変数の使用方法
以下のコードの例は、説明テキストと、BLOB を含んでいるデータベーステーブルから行を選択するためのフォームを生成します。「読み込み」をクリックすると、データベーステーブルから対応する行を選択し、それに含まれている BLOB を返す Info*Engine タスクが呼び出されます。
<%@page language="java" session="false" errorPage="../IEError.jsp"%>
<%@ taglib uri="http://www.ptc.com/infoengine/taglib/core" prefix="ie" %>
<html>
<head><title>Send Blob</title>
</head>
<body>
<P>This page prompts for a "name" of the BLOB file to retrieve from an
database and a "MIME type" to associate with the BLOB file. The
"name" is used to select a row in the table where the BLOB is
stored. The table must be created and BLOBs uploaded to rows in
the table before this example is run. The table could be
created using a SQL statement like 'CREATE TABLE BLOBTEST
(NAME VARCHAR(60),FILECONTENT BLOB)'.
<H2>Download File from BLOB Column</H2>
<P>The MIME type determines which application is opened when the BLOB is
received.  The MIME type is not stored in the table. Enter one of the
following MIME types:
<blockquote>'text/plain'<br>
'application/msword'<br>
'application/msexcel'<br>
'application/vnd.ms-excel'<br>
'image/gif'</blockquote>
<P>Include the single quotes in your MIME Type entry.</p>
<form method="POST" action="/Windchill/servlet/IE/tasks/com/company/DownloadBlob.xml"
enctype="multipart/form-data">
<TABLE>  <tr> <td align=right>
      <B><FONT FACE=arial,helvetica>Adapter Instance:
    </td>
    <td>
      <INPUT name = "instance" type="text" size=50>
    </td>
  </tr>
  <tr> <td align=right>
      <B><FONT FACE=arial,helvetica>Name:
    </td>
    <td>
      <INPUT name = "filename" type="text" size=50>
    </td>
  </tr>
  <tr> <td align=right>
      <B><FONT FACE=arial,helvetica>Mime Type:
    </td>
    <td>
      <INPUT name = "mimetype" type="text" size=50>
    </td>
  </tr>
  <tr> <td align=right>
      <INPUT type=submit NAME="submit" VALUE="Retrieve" id=button>
    </td>
  </tr></TABLE></form></body></html>
form 要素の action 属性で識別される DownloadBlob.xml タスクは、Info*Engine サーバーによって BLOB のダウンロード時に実行されるタスクです。このタスク (次のセクションで説明します) ではフォーム変数を使用して、アダプタインスタンスを識別し、BLOB が保存されるテーブル行内の BLOB に対応する名前を指定して、MIME タイプを設定します。
例: BLOB ダウンロードタスク
以下の DownloadBlob.xml のタスクの例では、1 つの Adapter Webject が使用されています。この Webject は、1 つの BLOB を Web ブラウザにダウンロードします。MIMETYPE パラメータで指定された MIME タイプはブラウザに戻され、BLOB を表示するときにブラウザで起動されるアプリケーションを決定します。Webject のパラメータで使用する @FORM 変数の値は、前のセクションで使用したフォームと似たフォームで指定できます。
このタスクの例では、データベースに以下のコラムがあると見なします。
BLOB の名前を含む NAME コラム
BLOB データを含む FILECONTENT コラム
<%@page language="java" session="false"%>
<%@ taglib uri="http://www.ptc.com/infoengine/taglib/core"
           prefix="ie" %>
<!--
    Possible MIME Types
      application/msword
      text/plain
      application/msexcel
      application/vnd.ms-excel
--/>
<ie:webject name="Send-Blob-Stream" type="OBJ">
  <ie:param name="INSTANCE" data="$(FORM[]instance[])"
                            default="jdbcAdapter"/>
  <ie:param name="CLASS" data="BLOBTEST"/>
  <ie:param name="ATTRIBUTE" data="FILECONTENT"/>
  <ie:param name="MIMETYPE" data="$(FORM[]mimetype[0])"/>
  <ie:param name="WHERE"
            data="(NAME='$(FORM[]filename[0])')"/>
  <ie:param name="GROUP_OUT" data="STATUS"/>
</ie:webject>