Download 2 WebFiles after another.

Hi,

I want to download 2 files immediately after another from my web application but whatever I try (download event, downloaded event, sleep etc.) I can do not get any further than downloading the last one of the two.
I also tried to use different WebFile objects but again no luck.

Is this even possible or do I have to zip the files first?

Hi Marcel,

I’m doing this with no problem. I have a property on the webpage DownloadFile() As WebFile. Then in the method I am:

Downloadfile.append New webfile
Dim i As Integer = DownloadFile.ubound
DownloadFile(i).UseCompression = False
DownloadFile(i) = WebFile.Open(f, false)
DownloadFile(i).ForceDownload = True

ShowURL(DownloadFile(i).URL)

This is actually in a loop where 1 or more files will be downloaded. With the improvements in R3 the webfile only holds a reference to the file, not the contents so I’m not worrying about cleaning up later. When the user navigates away from the page the cleanup happens.

HTH

Wayne

Interesting … I tried this and it never works… only downloads the last file.
What is the magic to get this to happen?

TIA

[quote=183752:@Ian Steele]Interesting … I tried this and it never works… only downloads the last file.
What is the magic to get this to happen?

TIA[/quote]

Looks like you are trying to download all the files in a single loop within an event, which may explain you only get the last file.

I had this problem too — second file would not download. My workaround was to do one immediately, then the second file downloaded from a 2 second Timer.

Yes clearly trying to download in a loop doesn’t work properly. There really does not seem to be an easy way around this.

Instead of doing it all at once, start the downloads one at a time in a timer.

Thanks Michel, that seems to work. Do you know if there is a method in Xojo/webfile to stop the browser automatically opening the file?

TIA

[quote=183906:@Ian Steele]Thanks Michel, that seems to work. Do you know if there is a method in Xojo/webfile to stop the browser automatically opening the file?
[/quote]

This is usually a setting of the browser itself. Some browsers display a dialog during download with a checkbox “Open at the end of download”.

Yes, thanks… I thought I might be able to override it. Just in case the user has it switched on and then downloads 50 video clips
that all open themselves.

[quote=183918:@Ian Steele]Yes, thanks… I thought I might be able to override it. Just in case the user has it switched on and then downloads 50 video clips
that all open themselves.[/quote]

The way it usually works on the net is that never a site throws several files at a user without asking first.

You may want to get confirmation from the user he actually wants all these files in one row, or get confirmation for each file.

Alternatively, do what Github does : pack all your files in a Zip file and let the user download that unique Zip.