0

Python's requests library supports chunked transfer:

Requests also supports Chunked transfer encoding for outgoing and incoming requests. To send a chunk-encoded request, simply provide a generator (or any iterator without a length) for your body

But the docs do not say when to use this approach.

I'm sending audio to an Azure API endpoint. The audio files are:

  • 98 KB on average
  • 478 KB max to date (and I do not expect them to get significantly bigger, because of a limit on the audio duration)
  • the median is at 76 KB
  1. Should I use a chunked approach or not?
  2. What's a reasonable threshold at which to start considering it?
metatoaster
  • 17,419
  • 5
  • 55
  • 66
Fabien Snauwaert
  • 4,995
  • 5
  • 52
  • 70
  • 1
    The use of a generator implies that it avoids the need to have the entire upload be already loaded up in memory (or disk), i.e. it can be generated/loaded up on the fly ([relevant thread](https://stackoverflow.com/questions/52458135/in-what-situations-should-you-actually-use-generators-in-python)), thus this is typically suitable for data generated on the fly, or data larger than what can fit in system memory. [Another relevant thread](https://stackoverflow.com/questions/2419281/content-length-header-versus-chunked-encoding) – metatoaster Feb 22 '23 at 10:39

0 Answers0