当前位置: 首页>>代码示例>>Python>>正文


Python http.MediaIoBaseUpload类代码示例

本文整理汇总了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
开发者ID:Acidburn0zzz,项目名称:google-api-python-client,代码行数:9,代码来源:test_http.py

示例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
开发者ID:Acidburn0zzz,项目名称:google-api-python-client,代码行数:11,代码来源:test_http.py

示例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))
开发者ID:nghgminhtri,项目名称:google-api-python-client,代码行数:9,代码来源:test_http.py

示例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()
开发者ID:Acidburn0zzz,项目名称:google-api-python-client,代码行数:13,代码来源:test_http.py

示例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
开发者ID:Acidburn0zzz,项目名称:google-api-python-client,代码行数:15,代码来源:test_http.py

示例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())
开发者ID:nghgminhtri,项目名称:google-api-python-client,代码行数:6,代码来源:test_http.py


注:本文中的googleapiclient.http.MediaIoBaseUpload类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。