You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 22 Current »

Name

Advanced Fileupload Plugin

Publisher

Apache Software Foundation

License

Open Source (ASL2)

Version

1.0-SNAPSHOT

Homepage

http://cwiki.apache.org/S2PLUGINS/Advanced+Fileupload+Plugin

{rate:title=Rating|theme=dynamic}

The Advanced File Upload Plugin is meant to provide added functionality to the previous Multipart Request handling within Struts 2. Prior to this plugin, Struts 2 utilized the Commons Fileupload but did not expose much of it's functionality. This plugin uses the same backend, but allows users to override beans and constants to make changes to the behavior of Commons Fileupload.

Introduction

The Advanced File Upload Plugin provides the following features:

  • Exposes a special action that can be asynchronously requested to view the status of uploads
  • Ability to set a threshold for the amount of memory consumed by Commons Fileupload's DiskItemFactory before writing data to disk

Usage

To use the plugin, simply install the jar file to your WEB-INF/lib.

Advanced

Since this plugin is a wrapper around the Commons Fileupload library, advanced usage requires knowledge of Commons Fileupload. Following is a list of the constants that can be overridden -

constant

explanation

default value

struts.fileuploadplugin.sizethreshold

Sets a threshold for the size of a file. If a file exceeds this threshold, it will be written to disk. Uploads consuming less than this threshold will only be stored in memory and never written to disk (unless you write it).

256

struts.fileuploadplugin.repositorypath

Directory where the plugin will write files to disk while processing the request. This is not permanent storage, files will be written temporarily here if they exceed the threshold.

/tmp

struts.fileuploadplugin.listenerupdatefrequency

This is the number of bytes to wait before calling the ProgressListener. The ProgressListener will be called frequently during the processing of the request. This allows you to throttle the frequency that it is called.

2048

struts.fileuploadplugin.isportletupload

Specifies whether the upload is happening within a Portlet.

false

struts.fileuploadplugin.timetokeepstatus

Currently, the status of uploads is stored in memory and tied to a user's session. This is a timeout setting instructing the app server to remove the status if it has not been written to or read from in the amount of time specified. Specify the number of seconds to hold onto the status in memory.

600

struts.multipart.handler

Simply specifies to struts2-core that the advanced file upload be used, rather than the built-in functionality.

upload-plugin

Example

Hopefully I can exploit this plugin once it is moved out of the sandbox by building an AJAX upload in one of the showcase apps.

Resources

Version History

Version

Date

Author

Notes

1.0

TBA (pending feedback)

Initial release

  • No labels