The key is - this must be super fast and efficient. These applications
deliver a high volume of files and we would prefer making the interaction as
small and fast as possible. We do not want to burden the main processing
loop with serving files if possible. We would prefer this to occur in
completely different process than our application if possible.




On 12/13/05 1:11 AM, "Davin" <[EMAIL PROTECTED]> wrote:

> 4.) Use a component action.
> 
> Wrap a hyperlink in a conditional making the hyperlink
> available to only authenticated users. Bind the
> hyperlink to a component action which downloads the
> file:
> 
> import java.io.*;
> 
> String filePath;
> 
> WOActionResults downloadFile() {
> try
> {
> filePath =
> getFilePathForCurrentResourceToDownload();
> WOResponse response = new WOResponse();
> String contentType =
> WOApplication.application().resourceManager().contentTypeForResourceNamed(file
> path);
> response.setHeader(contentType, "content-type");
> File f = new File(filepath);
> int bufferSize = (f.length() < 1024*1024) ? (int)
> f.length() : 1024*1024;
> response.setContentStream(new FileInputStream(f),
> bufferSize, (int) f.length());
> String fileName = NSPathUtilities.lastPathComponent(
> filepath );
> response.setHeader("filename="+fileName,
> "content-disposition");
> return response;
> }
> catch (Exception e)
> {
> WOResponse response = new WOResponse();
> response.appendContentString("Error downloading
> file: " + e);
> return response;
> }
> }
> 
> Davin.
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>  _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list      ([email protected])
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/webobjects-dev/drosenberg%40inquira.com
> 
> This email sent to [EMAIL PROTECTED]

-- 
Dov Rosenberg
Inquira Inc
370 Centerpointe Circle, ste 1178
Altamonte Springs, FL 32701
(407) 339-1177 x 102
(407) 339-6704 (fax)
[EMAIL PROTECTED]
AOL IM: dovrosenberg


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to