本文整理汇总了Python中googleapiclient.http.MediaIoBaseUpload类的典型用法代码示例。如果您正苦于以下问题:Python MediaIoBaseUpload类的具体用法?Python MediaIoBaseUpload怎么用?Python MediaIoBaseUpload使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MediaIoBaseUpload类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_media_io_base_upload_serializable
def test_media_io_base_upload_serializable(self):
f = open(datafile('small.png'), 'r')
upload = MediaIoBaseUpload(fd=f, mimetype='image/png')
try:
json = upload.to_json()
self.fail('MediaIoBaseUpload should not be serializable.')
except NotImplementedError:
pass
示例2: test_media_io_base_upload_streamable
def test_media_io_base_upload_streamable(self):
try:
import io
fd = io.BytesIO('stuff')
upload = MediaIoBaseUpload(
fd=fd, mimetype='image/png', chunksize=500, resumable=True)
self.assertEqual(True, upload.has_stream())
self.assertEqual(fd, upload.stream())
except ImportError:
pass
示例3: test_media_io_base_upload_from_file_io
def test_media_io_base_upload_from_file_io(self):
fd = FileIO(datafile('small.png'), 'r')
upload = MediaIoBaseUpload(
fd=fd, mimetype='image/png', chunksize=500, resumable=True)
self.assertEqual('image/png', upload.mimetype())
self.assertEqual(190, upload.size())
self.assertEqual(True, upload.resumable())
self.assertEqual(500, upload.chunksize())
self.assertEqual(b'PNG', upload.getbytes(1, 3))
示例4: test_media_io_base_upload_from_string_io
def test_media_io_base_upload_from_string_io(self):
f = open(datafile('small.png'), 'r')
fd = StringIO.StringIO(f.read())
f.close()
upload = MediaIoBaseUpload(
fd=fd, mimetype='image/png', chunksize=500, resumable=True)
self.assertEqual('image/png', upload.mimetype())
self.assertEqual(190, upload.size())
self.assertEqual(True, upload.resumable())
self.assertEqual(500, upload.chunksize())
self.assertEqual('PNG', upload.getbytes(1, 3))
f.close()
示例5: test_media_io_base_upload_from_bytes
def test_media_io_base_upload_from_bytes(self):
try:
import io
f = open(datafile('small.png'), 'r')
fd = io.BytesIO(f.read())
upload = MediaIoBaseUpload(
fd=fd, mimetype='image/png', chunksize=500, resumable=True)
self.assertEqual('image/png', upload.mimetype())
self.assertEqual(190, upload.size())
self.assertEqual(True, upload.resumable())
self.assertEqual(500, upload.chunksize())
self.assertEqual('PNG', upload.getbytes(1, 3))
except ImportError:
pass
示例6: test_media_io_base_upload_streamable
def test_media_io_base_upload_streamable(self):
fd = BytesIO(b'stuff')
upload = MediaIoBaseUpload(
fd=fd, mimetype='image/png', chunksize=500, resumable=True)
self.assertEqual(True, upload.has_stream())
self.assertEqual(fd, upload.stream())