NetTalk Central

Author Topic: Sending file after it is created  (Read 4013 times)

rjolda

  • Sr. Member
  • ****
  • Posts: 329
    • View Profile
    • Email
Sending file after it is created
« on: May 11, 2010, 04:07:55 AM »
Hi ,
I am calling a procedure to build a large PDF file and returning the name of the file that was created.
If it was created successfully I want it to download to the client.
What are the steps to automagically send the built file to the client?
Thanks,
Ron Jolda

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Sending file after it is created
« Reply #1 on: May 11, 2010, 04:54:45 AM »
Hi Ron,

I think the problem you will have (which is what  had) is that the browser will timeout before your PDF is generated unless you incorporate a technique to keep the connection alive.

What I ended up doing was creating a table with the file name and desc etc. I start with "generating report" and once it is ready I change the desc to "ready to view" or something along those lines and enable the button with the URL. I run the report on its own thread.

The advantage I see for my users is that they can easily recall a report they run earlier and they don't have to sit looking at a wirlie bird spinning around while a report is generated. they can go and do other things in the app and come back and check on the report from time to time.

I actually give my users both options of running and waiting or spooling except on posting screens where I force the report to spool as the user could not re-run the report if it timed out.

HTH's

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Sending file after it is created
« Reply #2 on: May 12, 2010, 01:03:24 AM »
Hi Ron,

Firstly, you need to think of this in the right way.

a) user asks for pdf - this is say a NetWebPage procedure
b) Inside NettWebPage, pdf is created, then sent (then deleted?)

You can't "push" the file to the client, they have to ask for it.

Kevins point is also valid - you need to keep the browser "interested" while the PDF file is being created.
The way to do this is
i) make sure the file is generated BEFORE the header is sent to the browser

ii) during generation - preferably inside whatever loops you have make a call to
p_web.NoOp()
Internally this method checks if a certain time has elapsed, if it has then it sends a small packet to the browser so that it knows you're still alive.

Cheers
Bruce

rjolda

  • Sr. Member
  • ****
  • Posts: 329
    • View Profile
    • Email
Re: Sending file after it is created
« Reply #3 on: May 12, 2010, 02:35:09 AM »
Bruce and Kevin,
My PDF file generation is QUICK - yes, I am aware of time out.
I want to kind of think of it as a REPORT  - the user asks for a report, it is created and then the client is notified that a file is ready for their client to download/view. I really do not want to make a link as they may build this file several times as stuff gets added to it.....
So, Bruce, in part b) - Inside NetWebPage, the PDF is created - how do I queue it up for sending to Client browser.
Thanks,
Ron

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile