Last updated February 05, 2009 05:45, by Igor Minar

grizzly-sendfile Plugins

grizzly-sendfile was designed to implement only the core download sending functionality, but allows additional functionality to be added to it in the form of plugins.

The plugin API is still currently very simple and still evolving. It's very likely that it will change slightly in the near future.

DownloadResultSender Plugin

DownloadResultSender is a plugin that sends the result of a download back to the application that instructed grizzly-sendfile to send a file.

It might be important for the application to know if the download succeeded, but since the application has no control over the download execution after the X-Sendfile header was set, there isn't a synchronous way to to this.

DownloadResultSender plugin resolves this issue in an asynchronous way. Simply create an HTTP interface (servlet, rails action, etc) capable of accepting requests from this plugin and DownloadResultSender will send the result of a download to this interface.

Configuration of the DownloadResultSender is done similarly to grizzly-sendfile via JVM options/parameters:

jvm option -Dcom.igorminar.grizzlysendfile.plugin.DownloadResultSender.DestinationUrl
description url to send download results to
required yes
example -Dcom.igorminar.grizzlysendfile.plugin.DownloadResultSender.DestinationUrl=http://myapp.com/results_receiver
-Dcom.igorminar.grizzlysendfile.plugin.DownloadResultSender.DestinationUrl=http://localhost:8080/results_receiver

The result will be sent as an HTTP POST request with these HTTP parameters:

name description
download_id download id assigned to the download by the application or by grizzly-sendfile
file_path path of the file sent
result HTTP response code - one of standard 200, 304, 403, 404 or custom 420 (client abort), 421 (client timeout)
speed average speed of the download in KB/s


Other Plugins

Currently the only other grizzly-sendfile plugin that was implemented is a GeoLocator plugin that denies download requests for IP addresses from embargoed countries. Because this plugin is specific to mediacast and depends on a internal webservice, its source code is not publicly available.

Plugin API

The plugin API is still under development and might change in the near future. The functionality will be preserved, only the API might change.

In order to write a plugin, one needs to implement com.igorminar.grizzlysendfile.plugin.SendfilePlugin interface.

Check out com.igorminar.grizzlysendfile.plugin.DownloadResultSender for an example plugin.

  • Mysql
  • Glassfish
  • Jruby
  • Rails
  • Nblogo
Terms of Use; Privacy Policy;
© 2010, Oracle Corporation and/or its affiliates
(revision 20100312.9442df5)
 
 
loading
Please Confirm