title: AWS Lambda: How to extract a tgz file in a S3 bucket and put it in another S3 bucket
body: <p>I have an S3 bucket named "Source". Many '.tgz' files are being pushed into that bucket in real-time. I wrote an Java code for extracting the '.tgz' file and pushing it into "Destination" bucket. I pushed my code as Lambda function. I got the '.tgz' file as InputStream in my Java code. How to extract it in Lambda ? I'm not able to create a file in Lambda, it throws "FileNotFound(Permission Denied)" in JAVA.</p>
  
  <pre><code>AmazonS3 s3Client = new AmazonS3Client();
  S3Object s3Object = s3Client.getObject(new GetObjectRequest(srcBucket, srcKey));
  InputStream objectData = s3Object.getObjectContent();
  File file = new File(s3Object.getKey());
  OutputStream writer = new BufferedOutputStream(new FileOutputStream(file)); &lt;--- It throws FileNotFound(Permission denied) here
  </code></pre>