title: Trouble Transferring data from FTP server to S3 via stream using Python
body: <p>I am looking to transfer the contents of a folder from an ftp server to a bucket in s3 without writing to disk. Currently, s3 is getting all of the names of the files in the folder, but none of the actual data. Each file in the folder is only a few bytes. I'm not quite sure why it is not uploading the whole file.</p>
  
  <pre><code>from ftplib import FTP
  import io 
  import boto3
  
  
  s3= boto3.resource('s3')
  
  ftp = FTP('ftp.ncbi.nlm.nih.gov')
  ftp.login()
  ftp.cwd('pubchem/RDF/descriptor/compound')
  
  address =  'ftp.ncbi.nlm.nih.gov/pubchem/RDF/descriptor/compound/'
  
  filelist = ftp.nlst()
  
  for x in range(0, len(filelist)-1):
      myfile = io.BytesIO()
      filename = 'RETR ' + filelist[x]
      resp = ftp.retrbinary(filename, myfile.write)
      myfile.seek(0)
      path = address + filelist[x]
      #putting file on s3
      s3.Object(s3bucketname, path).put(Body = resp)
  
  
  ftp.quit()
  </code></pre>
  
  <p>Is there any way to make sure the whole file is uploaded?</p>