How to use the s3transfer.compat.six.BytesIO function in s3transfer

To help you get started, we’ve selected a few s3transfer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github boto / s3transfer / tests / functional / test_download.py View on Github external
def create_stubbed_responses(self):
        return [
            {
                'method': 'head_object',
                'service_response': {
                    'ContentLength': len(self.content)
                }
            },
            {
                'method': 'get_object',
                'service_response': {
                    'Body': six.BytesIO(self.content[0:4])
                }
            },
            {
                'method': 'get_object',
                'service_response': {
                    'Body': six.BytesIO(self.content[4:8])
                }
            },
            {
                'method': 'get_object',
                'service_response': {
                    'Body': six.BytesIO(self.content[8:])
                }
github boto / s3transfer / tests / functional / test_download.py View on Github external
def test_download_empty_object(self):
        self.content = b''
        self.stream = six.BytesIO(self.content)
        self.add_head_object_response()
        self.add_successful_get_object_responses()
        future = self.manager.download(
            self.bucket, self.key, self.filename, self.extra_args)
        future.result()

        # Ensure that the empty file exists
        with open(self.filename, 'rb') as f:
            self.assertEqual(b'', f.read())
github boto / s3transfer / tests / unit / test_download.py View on Github external
def add_get_responses(self):
        chunksize = self.config.multipart_chunksize
        for i in range(0, len(self.content), chunksize):
            if i + chunksize > len(self.content):
                stream = six.BytesIO(self.content[i:])
                self.stubber.add_response('get_object', {'Body': stream})
            else:
                stream = six.BytesIO(self.content[i:i+chunksize])
                self.stubber.add_response('get_object', {'Body': stream})