You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Peter Dawn <pe...@gmail.com> on 2006/09/05 03:07:18 UTC

Tap3 file system help

guys,

i am trying to implement a upload and download functionality within my web app.

so for upload, the user selects a location they want to upload from,
click upload and i upload the file and save it in my local server set
directory.

for download, they select the file they want to download and the
folder they want to download to, click download and i download the
file into their set local file system.

can somebody help me out here. i am going to try and read about some
java i/o and see if i can implement this. thanks.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Tap3 file system help

Posted by Peter Dawn <pe...@gmail.com>.
cheers mate. i will give this a try and see how i go.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: Tap3 file system help

Posted by Mark Stang <ms...@pingidentity.com>.
Peter,
I believe it is built into Tapestry kinda sorta:

    public void download(IRequestCycle cycle)
    {
        if (getOkToDownload())
        {
            HttpServletResponse response = getPage().getRequestCycle().getRequestContext().getResponse();
            if (getNoCache())
            {
                response.setDateHeader("max-age", 0);
                response.setDateHeader("Expires", 0);
            }
            response.setHeader("Content-transfer-encoding", "binary");
            response.setContentType(getContentType());
            response.setHeader("Content-disposition", "attachment; filename=" + getFilename());
            response.setContentLength(getRawBytes().length);    
            try
            {
                ServletOutputStream bytesOut = response.getOutputStream();
                bytesOut.write(getRawBytes());
                response.flushBuffer();
            }
            catch (IOException io)
            {
                log.debug(getButtonText() + " this file caused an IOException! " + io);
            }
        }
    }

This is part of a custom component.  It also has a field for filename that is a string that is passed in.

For Upload, there is "@Upload" in the component reference.

regards,

Mark

-----Original Message-----
From: Peter Dawn [mailto:petedawn@gmail.com]
Sent: Mon 9/4/2006 7:07 PM
To: tapestry-user@jakarta.apache.org
Subject: Tap3 file system help
 
guys,

i am trying to implement a upload and download functionality within my web app.

so for upload, the user selects a location they want to upload from,
click upload and i upload the file and save it in my local server set
directory.

for download, they select the file they want to download and the
folder they want to download to, click download and i download the
file into their set local file system.

can somebody help me out here. i am going to try and read about some
java i/o and see if i can implement this. thanks.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org



RE: Tap3 file system help

Posted by Mark Stang <ms...@pingidentity.com>.
Peter,
I believe it is built into Tapestry kinda sorta:

    public void download(IRequestCycle cycle)
    {
        if (getOkToDownload())
        {
            HttpServletResponse response = getPage().getRequestCycle().getRequestContext().getResponse();
            if (getNoCache())
            {
                response.setDateHeader("max-age", 0);
                response.setDateHeader("Expires", 0);
            }
            response.setHeader("Content-transfer-encoding", "binary");
            response.setContentType(getContentType());
            response.setHeader("Content-disposition", "attachment; filename=" + getFilename());
            response.setContentLength(getRawBytes().length);    
            try
            {
                ServletOutputStream bytesOut = response.getOutputStream();
                bytesOut.write(getRawBytes());
                response.flushBuffer();
            }
            catch (IOException io)
            {
                log.debug(getButtonText() + " this file caused an IOException! " + io);
            }
        }
    }

This is part of a custom component.  It also has a field for filename that is a string that is passed in.

For Upload, there is "@Upload" in the component reference.

regards,

Mark

-----Original Message-----
From: Peter Dawn [mailto:petedawn@gmail.com]
Sent: Mon 9/4/2006 7:07 PM
To: tapestry-user@jakarta.apache.org
Subject: Tap3 file system help
 
guys,

i am trying to implement a upload and download functionality within my web app.

so for upload, the user selects a location they want to upload from,
click upload and i upload the file and save it in my local server set
directory.

for download, they select the file they want to download and the
folder they want to download to, click download and i download the
file into their set local file system.

can somebody help me out here. i am going to try and read about some
java i/o and see if i can implement this. thanks.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org