title: Write file and objects to amazon s3
body: <p>I am using amazon S3 to distribute the dynamically generated files to S3.</p>
  
  <p>At a local server, I can use </p>
  
  <pre><code>destination = open(VIDEO_DIR + newvideo.name, 'wb+')
  </code></pre>
  
  <p>to store generated videos to the location VIDEO_DIR.newvideo.name</p>
  
  <p>Is there feasible way to change VIDEO_DIR to S3 endpoint location. So the dynamically generated videos can be written to S3 server directly?</p>
  
  <p>Another question is: is there any feasible way to write an object to S3 directly? For example, a <code>chunklet=Chunklet()</code>, how to write this chunklet object to S3 server directly?</p>
  
  <p>I can do this first create a local file and use S3 API. For example, </p>
  
  <pre><code>mime = mimetypes.guess_type(filename)[0]
  k = Key(b)
  k.key = filename
  k.set_metadata("Content-Type", mime)
  k.set_contents_from_filename(filename)
  k.set_acl('public-read')
  </code></pre>
  
  <p>But I want to improve the efficiency. Python is used. </p>