6
I have an application where I give an answer by downloading a certain file on the server to the client. I zip the image files that are in a folder on the server and give an answer by manipulating the headers so that the file is downloaded.
I noticed that when this generated file is a little bigger, there is a delay to download it, but it is not displayed in the browser the remaining time to download based on the file size.
An example written in Aspx Webform:
string fullpath = GenerateZippedPhotos(id);
response.ContentType = "application/zip";
response.AddHeader("content-disposition", "filename=remessa_fotos.zip");
response.WriteFile(fullpath);
response.Flush();
To fix the problem described above, what needs to be done?
Is there any way to "talk to the browser" the size of the file being downloaded?
I didn’t tag [tag:csharp] because it’s not a language-specific problem
– Wallace Maxters
Addheader( "Content-Length", size )
– Bacco
That alone will solve?
– Wallace Maxters
I can’t imagine the need for more than that,
– Bacco
@Does Guilhermenascimento really think he needs the C TAG? For me, I just wanted to ask a question in the global context :D
– Wallace Maxters
If you zip in one
stream
(without having to write to the hard drive, just in the socket), which is the most standard way to send an arbitrary zip that you don’t want to store on the server, you don’t know the size a priori. I suffer this with Jenkins and Gitlab when I ask to download a zipped directory– Jefferson Quesado
@Jeffersonquesado truth, staying in the memory, which anyway was already before recording, although I do not know the behavior of the platform . net (and c#), if the zip is large I don’t know how expensive it could be, maybe a 256k upload and use a flush, even a download limiter, another idea would be a pro zip cache to avoid rework, but if I go into this the suggestions will go far :)
– Guilherme Nascimento