2

I have some static files on the server, and when a user click download, I want the server to zip the files and send to the client at the same time (instead buffering it in server's memory or writing to local disk file system first.), just like when you download a repo from GitHub.

Transfer-Encoding: chunked need to be used I guess.

question related to Examples that send unkown size data with http chunked header?

Rick
  • 7,007
  • 2
  • 49
  • 79
  • What (framework) are you using to send your HTTP response? – Davis Herring Jun 08 '19 at 16:01
  • @DavisHerring I am only familiar with Flask by far: ( . – Rick Jun 08 '19 at 16:37
  • And do you know how to send a hello world as a chunked transfer with it? (Is that the point of your other question?) – Davis Herring Jun 08 '19 at 16:48
  • @DavisHerring No I don't. I haven't used `Transfer-Encoding: chunked` before. For the other question, I just wanna know what are the practical examples related to the `Transfer-Encoding: chunked` header. And sending files to client while zipping them on the server is the (only) one that I've so far known. – Rick Jun 08 '19 at 17:18
  • Maybe you should ask that question first—the part with `zip` is pretty well separated. – Davis Herring Jun 08 '19 at 17:38
  • @DavisHerring Hmmm. I thought there were some kind of `zip` library to call :( . Any related material recommended? Couldn't find anything useful on the net. – Rick Jun 08 '19 at 17:45
  • There won’t be a `zip.write_chunked` function, but writing it is straightforward (and a fine StackOverflow question)—*after* you know how to write whatever data in a chunked fashion (with Flask). – Davis Herring Jun 08 '19 at 18:01
  • I know there isn't a `zip.write_chunked` like function. What I mean is a library that handles zipping/compressing files in Python. Are you urging me to ask another question..? I've already asked 2 questions for this.. – Rick Jun 08 '19 at 18:10
  • You have many questions (which is fine): Why use chunked encoding? How do I use it in Flask? How can I compress files in Python? How can I send the compressed data directly via the chunked encoding? You’ve asked the first and last, but you need the middle two. The second is very easy to research yourself, of course, and the third might be as well; you can just edit this question once you understand those two if you succeed. – Davis Herring Jun 08 '19 at 18:16

0 Answers0