title: How to split a file into smaller pieces before sending
body: <p>How do I get the following code to break up large files into smaller parts and send those parts, instead of sending the whole file? It fails to send large files (Tested with an ubuntu iso around 600mb)</p>
  
  <pre><code>...some code
  # file transfer
      with open(sendFile, "rb") as f:
          while 1:
              fileData = f.read()
              if fileData == "": break
              # send file
              s.sendall(EncodeAES(cipher, fileData))
      f.close()
  ...more code
  </code></pre>
  
  <p>I tried with f.read(1024), but that didn't work.</p>
  
  <p>Finally, when splitting up the files, I would need to be able to put the parts together again.</p>
  
  <p>I'm also encrypting the files using PyCrypto, if that has any impact on what I'm trying to do. Guess it would be smartest to encrypt the seperate parts, instead of encrypting the whole file and then splitting that into parts.</p>
  
  <p>Hope the above code is enough. If not, I'll update with more code.</p>