publishers_5.py 336 B

1234567891011
  1. def write_file(file_data, destination):
  2. """Write Django uploaded file object to disk incrementally in order to
  3. avoid sucking up all of the system's RAM by reading the whole thing in to
  4. memory at once.
  5. """
  6. out = open(destination, "wb+")
  7. for chunk in file_data.chunks():
  8. out.write(chunk)
  9. out.close()