1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

DWRでファイルをアップロードする方法

Last updated at Posted at 2015-02-05

DWRは、JavaでAjaxを開発できるライブラリです。
DWRでファイルをアップロードする方法を紹介します。

とりあえず、以下の公式サイトを和訳します。
公式サイト(画像やバイナリファイルの変換)

画像ファイルやバイナリファイルの変換

DWR3.0の特徴は、新しいFileConverterです。FileConverterは次のバイナリファイルを扱います。

  • 画像 (java.awt.BufferedImageの子孫クラス)
  • InputStreams (java.io.InputStreamの子孫クラス)
  • FileTransferオブジェクト(org.directwebremoting.io.FileTransfer)

アップロードするために、commons-fileuploadとcommons-ioをclasspathに設定してください。
詳細は、commons-uploadの依存性を表した図見てください。
JARファイルを間違うと、DWRが"file uploads not supported"というエラーメッセージを出すでしょう。

最大アップロードサイズ

ファイルアップロードの上限サイズは、DWRサーブレットのinit-param "fileUploadMaxBytes" で指定できます。
このパラメータは次のように指定してください。

<init-param>
    <param-name>fileUploadMaxBytes</param-name>
    <param-value>5000</param-value>
</init-param>
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?