INNER CODE UNIT · Python

download_from_s3

miztiik/AWS-Demos · how-to-examples/iam-s3-sqs-sns-video-transcoder.py:445

    def download_from_s3(self, s3_file):
        """
        Download a file from the S3 output bucket to your hard drive.
        """
        destination_path = os.path.join(
            self.converted_directory,
            os.path.basename(s3_file)
        )
        body = self.out_bucket.Object(s3_file).get()['Body']
        with open(destination_path, 'wb') as dest:
            # Here we write the file in chunks to prevent
            # loading everything into memory at once.
            for chunk in iter(lambda: body.read(4096), b''):
                dest.write(chunk)

        print("Downloaded {0}".format(destination_path))

    # End boto-specific methods.

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…