コード例 #1
0
 def _upload_part(self, large_file_id, part_number, part_data):
     part_stream = six.BytesIO(part_data)
     upload_info = self.simulator.get_upload_part_url(
         self.api_url, self.account_auth_token, large_file_id)
     self.simulator.upload_part(upload_info['uploadUrl'],
                                upload_info['authorizationToken'],
                                part_number, len(part_data),
                                hex_sha1_of_bytes(part_data), part_stream)
コード例 #2
0
 def testThree(self):
     file1 = self.bucket.start_large_file('file1.txt', 'text/plain', {})
     content = six.b('hello world')
     content_sha1 = hex_sha1_of_bytes(content)
     large_file_upload_state = mock.MagicMock()
     large_file_upload_state.has_error.return_value = False
     self.bucket._upload_part(file1.file_id, 1, (0, 11),
                              UploadSourceBytes(content),
                              large_file_upload_state)
     self.bucket._upload_part(file1.file_id, 2, (0, 11),
                              UploadSourceBytes(content),
                              large_file_upload_state)
     self.bucket._upload_part(file1.file_id, 3, (0, 11),
                              UploadSourceBytes(content),
                              large_file_upload_state)
     expected_parts = [
         Part('9999', 1, 11, content_sha1),
         Part('9999', 2, 11, content_sha1),
         Part('9999', 3, 11, content_sha1),
     ]
     self.assertEqual(
         expected_parts,
         list(self.bucket.list_parts(file1.file_id, batch_size=1)))
コード例 #3
0
 def setUp(self):
     self.data = b'01234567'
     self.stream = StreamWithHash(six.BytesIO(self.data))
     self.hash = hex_sha1_of_bytes(self.data)
     self.expected = self.data + self.hash.encode()