How to prevent download of exported CSV file before it's ready?

Hi,

So I am generating reports which I then present the user a button to export the report.

When they click on the export button I run Export CSV File in server action.

Once I get a success on the server action I start the download of the file.

My problem is depending on the size of the report, the excel file is sometimes still being written to, and therefore I get one of two issues.

The first one I get some of the times.
"Message": "The process cannot access the file 'C:\\wwwMe2You\\reports\\3_21-Apr-2020-1509_Report.csv' because it is being used by another process.",

Or the second is the download will start and somehow pull down the file missing a lot of data because the file had not finished being written to.

As the server action sends back a success even though the files are still been written too there is no way to prevent the download from starting.

How can I overcome this issue?

Thanks,
Ray

I’m sure its well too late, but you could put the steps into a workflow and add a ‘wait’ step before commencing the download.

Did you ever find a working solution for this, @raymantle?

@brad The only option I had was to add a condition based on the number of days selected for the report and add a wait where applicable.

eg.
If the number of days is < 30, Export the report with no “Wait”
If the number of days is between 30 and 180, Export the report with “Wait” 1500
If the number of days is > 180, Export the report with “Wait” 5000

I got the wait times from trial and error based on the amount of data was being returned.
It’s not the prettiest, but no other options were offered by the community.

Ray

Why would you need a wait for this (and wait is only available for node)?

You can add query > export > download steps.

@Teodor, no matter what I tried, the report was still being written to in windows (ie. when viewing in Explorer you could see the file size still growing) even after “Export CSV File” returned a 200 and the “Download File” which was the next step would run and therefore download a partial file.

I had the “wait” in the Flow.
image

How many records are you trying to export and how many columns is the table?
I tested with a 8k records table and it worked fine.

The last one was 266,332 rows, with 28 columns.

image
image

The file size is 52mb
image

This could also be to do with the performance of the server, and therefore taking a while to write the file.

I see that’s quite a huge file indeed. Maybe @patrick can suggest a solution for this here.

Which server model do you use (NodeJS/PHP/ASP.NET)?

Hi @patrick,

I am using ASP.net with IIS on Windows Server 2012 R2.

Regards,
Ray.

You can test this update.

DMXzone.ServerConnect.Export.zip (6.3 KB)