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


Python SCSBucket.put_bucket方法代码示例

本文整理汇总了Python中sinastorage.bucket.SCSBucket.put_bucket方法的典型用法代码示例。如果您正苦于以下问题:Python SCSBucket.put_bucket方法的具体用法?Python SCSBucket.put_bucket怎么用?Python SCSBucket.put_bucket使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sinastorage.bucket.SCSBucket的用法示例。


在下文中一共展示了SCSBucket.put_bucket方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_update_file_meta

# 需要导入模块: from sinastorage.bucket import SCSBucket [as 别名]
# 或者: from sinastorage.bucket.SCSBucket import put_bucket [as 别名]
    def test_update_file_meta(self):
        scs = SCSBucket(self.bucket_name)
        try:
            scs.put_bucket('public-read-write')
        except:
            self.fail('create bucket:%s is failed'%self.bucket_name)
        content = u'this is a file content text!!'
        scs.put(self.object_key, content)
          
        canned_acl = 'public-read-write'                #快捷ACL
        metadata = {}                                   #自定义文件属性信息
        metadata['author'] = 'dage'
        metadata['home'] = 'tianjin'
        metadata['age'] = '18'
        mimetype = 'text/plain'
        scs.update_meta(self.object_key, metadata=metadata, acl=canned_acl, mimetype=mimetype)
      
        file_info = scs.info(self.object_key)
        #assert metadata
        self.assertEqual(metadata['author'], file_info['metadata']['author'], 'The response metadata[\'author\'] is not match')
        self.assertEqual(metadata['home'], file_info['metadata']['home'], 'The response metadata[\'home\'] is not match')
        self.assertEqual(metadata['age'], file_info['metadata']['age'], 'The response metadata[\'age\'] is not match')
        #assert content-type
#         print file_info['headers']
#TODO:服务器问题         self.assertEqual(mimetype, file_info['headers']['content-type'], 'The response content-type is not match')
        #acl
        file_aclInfo = scs.acl_info(self.object_key)
        self.assertTrue(ACL.ACL_GROUP_ANONYMOUSE in file_aclInfo['ACL'], 'The acl dose not contains GRPS000000ANONYMOUSE group')
        self.assertTrue(ACL.ACL_READ in file_aclInfo['ACL'][ACL.ACL_GROUP_ANONYMOUSE], 'The acl GRPS000000ANONYMOUSE group hasn\'t read right')
        self.assertTrue(ACL.ACL_WRITE in file_aclInfo['ACL'][ACL.ACL_GROUP_ANONYMOUSE], 'The acl GRPS000000ANONYMOUSE group hasn\'t write right')
开发者ID:SinaCloudStorage,项目名称:SinaStorage-SDK-Python,代码行数:32,代码来源:test.py

示例2: test_update_file_acl

# 需要导入模块: from sinastorage.bucket import SCSBucket [as 别名]
# 或者: from sinastorage.bucket.SCSBucket import put_bucket [as 别名]
 def test_update_file_acl(self):
     scs = SCSBucket(self.bucket_name)
     try:
         scs.put_bucket('public-read-write')
     except:
         self.fail('create bucket:%s is failed'%self.bucket_name)
     content = u'this is a file content text!!'
     canned_acl = 'private'                #快捷ACL
     scs.put(key=self.object_key, data=content, acl=canned_acl)
       
     #设置ACL
     acl = {}
     acl[ACL.ACL_GROUP_ANONYMOUSE] = [ACL.ACL_READ, ACL.ACL_WRITE, ACL.ACL_READ_ACP]
     acl[ACL.ACL_GROUP_CANONICAL] = [ACL.ACL_READ_ACP,ACL.ACL_WRITE_ACP, ACL.ACL_READ]
     user_id = 'SINA0000001001AABBCC'
     acl[user_id] = [ACL.ACL_WRITE, ACL.ACL_READ]
     scs.update_acl(self.object_key, acl)
     #assert
     file_aclInfo = scs.acl_info(self.object_key)
     #ACL_GROUP_ANONYMOUSE
     self.assertTrue(ACL.ACL_GROUP_ANONYMOUSE in file_aclInfo['ACL'], 'The acl dose not contains GRPS000000ANONYMOUSE group')
     self.assertTrue(ACL.ACL_READ in file_aclInfo['ACL'][ACL.ACL_GROUP_ANONYMOUSE], 'The acl GRPS000000ANONYMOUSE group hasn\'t read right')
     self.assertTrue(ACL.ACL_WRITE in file_aclInfo['ACL'][ACL.ACL_GROUP_ANONYMOUSE], 'The acl GRPS000000ANONYMOUSE group hasn\'t write right')
     self.assertTrue(ACL.ACL_READ_ACP in file_aclInfo['ACL'][ACL.ACL_GROUP_ANONYMOUSE], 'The acl GRPS000000ANONYMOUSE group hasn\'t read_acp right')
     #ACL_GROUP_CANONICAL
     self.assertTrue(ACL.ACL_GROUP_CANONICAL in file_aclInfo['ACL'], 'The acl dose not contains GRPS0000000CANONICAL group')
     self.assertTrue(ACL.ACL_READ in file_aclInfo['ACL'][ACL.ACL_GROUP_CANONICAL], 'The acl GRPS0000000CANONICAL group hasn\'t read right')
     self.assertTrue(ACL.ACL_WRITE_ACP in file_aclInfo['ACL'][ACL.ACL_GROUP_CANONICAL], 'The acl GRPS0000000CANONICAL group hasn\'t write_acp right')
     self.assertTrue(ACL.ACL_READ_ACP in file_aclInfo['ACL'][ACL.ACL_GROUP_CANONICAL], 'The acl GRPS0000000CANONICAL group hasn\'t read_acp right')
     #user_id
     self.assertTrue(user_id in file_aclInfo['ACL'], 'The acl dose not contains user_id group')
     self.assertTrue(ACL.ACL_READ in file_aclInfo['ACL'][user_id], 'The acl user_id group hasn\'t read right')
     self.assertTrue(ACL.ACL_WRITE in file_aclInfo['ACL'][user_id], 'The acl user_id group hasn\'t write right')
开发者ID:SinaCloudStorage,项目名称:SinaStorage-SDK-Python,代码行数:35,代码来源:test.py

示例3: test_copy_file

# 需要导入模块: from sinastorage.bucket import SCSBucket [as 别名]
# 或者: from sinastorage.bucket.SCSBucket import put_bucket [as 别名]
 def test_copy_file(self):
     scs = SCSBucket(self.bucket_name)
     try:
         scs.put_bucket('public-read-write')
     except:
         self.fail('create bucket:%s is failed'%self.bucket_name)
           
     scs.putFile(self.object_key, self.local_file_name)
       
     canned_acl = 'public-read'                #快捷ACL
     metadata = {}                             #自定义文件属性信息
     metadata['author'] = 'copied'
     metadata['home'] = 'beijing'
     metadata['age'] = '189'
     mimetype = 'text/plain'
     scs.copy(source='/'+self.bucket_name+'/'+self.object_key, 
              key=self.object_key+'_copied', acl=canned_acl, 
              metadata=metadata, mimetype=mimetype)
       
     copied_file_aclInfo = scs.acl_info(self.object_key+'_copied')
     self.assertTrue(ACL.ACL_GROUP_ANONYMOUSE in copied_file_aclInfo['ACL'], 'The acl dose not contains GRPS000000ANONYMOUSE group')
     self.assertTrue(ACL.ACL_READ in copied_file_aclInfo['ACL'][ACL.ACL_GROUP_ANONYMOUSE], 'The acl GRPS000000ANONYMOUSE group hasn\'t read right')
       
     copied_file_info = scs.info(self.object_key+'_copied')
     #assert metadata
     self.assertEqual(metadata['author'], copied_file_info['metadata']['author'], 'The response metadata[\'author\'] is not match')
     self.assertEqual(metadata['home'], copied_file_info['metadata']['home'], 'The response metadata[\'home\'] is not match')
     self.assertEqual(metadata['age'], copied_file_info['metadata']['age'], 'The response metadata[\'age\'] is not match')
     #assert content-type
     self.assertEqual(mimetype, copied_file_info['headers']['content-type'], 'The response content-type is not match')
开发者ID:SinaCloudStorage,项目名称:SinaStorage-SDK-Python,代码行数:32,代码来源:test.py

示例4: test_get_file_meta

# 需要导入模块: from sinastorage.bucket import SCSBucket [as 别名]
# 或者: from sinastorage.bucket.SCSBucket import put_bucket [as 别名]
 def test_get_file_meta(self):
     scs = SCSBucket(self.bucket_name)
     try:
         scs.put_bucket('public-read-write')
     except:
         self.fail('create bucket:%s is failed'%self.bucket_name)
       
     metadata = {}                                   #自定义文件属性信息
     metadata['author'] = 'dage'
     metadata['home'] = 'tianjin'
     metadata['age'] = '18'
     mimetype = 'text/plain'
       
     scs.putFile(key=self.object_key, filePath=self.local_file_name,
                 metadata=metadata, mimetype=mimetype)
           
     metaResult = scs.meta(self.object_key)
       
     self.assertEqual(self.object_key, metaResult['File-Name'], 'The meta[\'File-Name\'] is not equals '+self.object_key)
     self.assertEqual(mimetype, metaResult['Type'], 'The meta[\'Type\'] is not equals '+mimetype)
     self.assertTrue(metaResult['Content-SHA1'] is not None, 'The meta[\'Content-SHA1\'] is None')
     self.assertTrue(metaResult['Content-MD5'] is not None, 'The meta[\'Content-MD5\'] is None')
     self.assertTrue(metaResult['Owner'] is not None, 'The meta[\'Owner\'] is None')
       
     self.assertTrue('x-amz-meta-author' in metaResult['File-Meta'], 'File-Meta dose not contains x-amz-meta-author key')
     self.assertEqual(metadata['author'], metaResult['File-Meta']['x-amz-meta-author'], 'The metaResult[\'File-Meta\'][\'x-amz-meta-author\'] value is not match')
     self.assertTrue('x-amz-meta-home' in metaResult['File-Meta'], 'File-Meta dose not contains x-amz-meta-home key')
     self.assertEqual(metadata['home'], metaResult['File-Meta']['x-amz-meta-home'], 'The metaResult[\'File-Meta\'][\'x-amz-meta-home\'] value is not match')
     self.assertTrue('x-amz-meta-age' in metaResult['File-Meta'], 'File-Meta dose not contains x-amz-meta-age key')
     self.assertEqual(metadata['age'], metaResult['File-Meta']['x-amz-meta-age'], 'The metaResult[\'File-Meta\'][\'x-amz-meta-age\'] value is not match')
开发者ID:SinaCloudStorage,项目名称:SinaStorage-SDK-Python,代码行数:32,代码来源:test.py

示例5: test_put_file_relax

# 需要导入模块: from sinastorage.bucket import SCSBucket [as 别名]
# 或者: from sinastorage.bucket.SCSBucket import put_bucket [as 别名]
 def test_put_file_relax(self):
     scs = SCSBucket(self.bucket_name)
     try:
         scs.put_bucket('public-read-write')
     except:
         self.fail('create bucket:%s is failed'%self.bucket_name)
          
     scs.put(self.object_key, 'fileContent...fileContent...fileContent...fileContent...fileContent...')
      
     orign_file_metaResult = scs.meta(self.object_key)
      
     canned_acl = 'public-read-write'                #快捷ACL
     metadata = {}                                   #自定义文件属性信息
     metadata['author'] = 'dage'
     metadata['home'] = 'tianjin'
     metadata['age'] = '18'
     mimetype = 'text/plain'
     scs.put_relax(key=self.object_key+'_relax', sina_sha1=orign_file_metaResult['Content-SHA1'], 
                   s_sina_length=orign_file_metaResult['Size'], acl=canned_acl, 
                   metadata=metadata, mimetype=mimetype)
      
     relax_file_aclInfo = scs.acl_info(self.object_key+'_relax')
     self.assertTrue(ACL.ACL_GROUP_ANONYMOUSE in relax_file_aclInfo['ACL'], 'The acl dose not contains GRPS000000ANONYMOUSE group')
     self.assertTrue(ACL.ACL_READ in relax_file_aclInfo['ACL'][ACL.ACL_GROUP_ANONYMOUSE], 'The acl GRPS000000ANONYMOUSE group hasn\'t read right')
     self.assertTrue(ACL.ACL_WRITE in relax_file_aclInfo['ACL'][ACL.ACL_GROUP_ANONYMOUSE], 'The acl GRPS000000ANONYMOUSE group hasn\'t write right')
      
     relax_file_info = scs.info(self.object_key+'_relax')
     #assert metadata
     self.assertEqual(metadata['author'], relax_file_info['metadata']['author'], 'The response metadata[\'author\'] is not match')
     self.assertEqual(metadata['home'], relax_file_info['metadata']['home'], 'The response metadata[\'home\'] is not match')
     self.assertEqual(metadata['age'], relax_file_info['metadata']['age'], 'The response metadata[\'age\'] is not match')
     #assert content-type
     self.assertEqual(mimetype, relax_file_info['headers']['content-type'], 'The response content-type is not match')
开发者ID:SinaCloudStorage,项目名称:SinaStorage-SDK-Python,代码行数:35,代码来源:test.py

示例6: test_remove_bucket

# 需要导入模块: from sinastorage.bucket import SCSBucket [as 别名]
# 或者: from sinastorage.bucket.SCSBucket import put_bucket [as 别名]
 def test_remove_bucket(self):
     scs = SCSBucket(self.bucket_name)
     scs.put_bucket()
       
     try:
         scs.delete_bucket()
     except:
         self.fail('Remove bucket:%s is failed'%self.bucket_name)
开发者ID:SinaCloudStorage,项目名称:SinaStorage-SDK-Python,代码行数:10,代码来源:test.py

示例7: test_create_bucket_with_acl

# 需要导入模块: from sinastorage.bucket import SCSBucket [as 别名]
# 或者: from sinastorage.bucket.SCSBucket import put_bucket [as 别名]
 def test_create_bucket_with_acl(self):
     scs = SCSBucket(self.bucket_name)
     try:
         scs.put_bucket('public-read-write')
     except:
         self.fail('create bucket:%s is failed'%self.bucket_name)
           
     metaResult = scs.meta()
     self.assertTrue(ACL.ACL_GROUP_ANONYMOUSE in metaResult['ACL'], 'The bucket:%s acl dose not contains GRPS000000ANONYMOUSE group'%self.bucket_name)
     self.assertTrue(ACL.ACL_READ in metaResult['ACL'][ACL.ACL_GROUP_ANONYMOUSE], 'The bucket:%s acl GRPS000000ANONYMOUSE group hasn\'t read right'%self.bucket_name)
     self.assertTrue(ACL.ACL_WRITE in metaResult['ACL'][ACL.ACL_GROUP_ANONYMOUSE], 'The bucket:%s acl GRPS000000ANONYMOUSE group hasn\'t write right'%self.bucket_name)
开发者ID:SinaCloudStorage,项目名称:SinaStorage-SDK-Python,代码行数:13,代码来源:test.py

示例8: test_delete_file

# 需要导入模块: from sinastorage.bucket import SCSBucket [as 别名]
# 或者: from sinastorage.bucket.SCSBucket import put_bucket [as 别名]
 def test_delete_file(self):
     scs = SCSBucket(self.bucket_name)
     try:
         scs.put_bucket('public-read-write')
     except:
         self.fail('create bucket:%s is failed'%self.bucket_name)
           
     content = u'this is a file content text!!'
     scs.put(self.object_key, content)
       
     try:
         scs.delete(self.object_key)
     except:
         self.fail('Delete file is failed')
开发者ID:SinaCloudStorage,项目名称:SinaStorage-SDK-Python,代码行数:16,代码来源:test.py

示例9: test_get_bucket_meta

# 需要导入模块: from sinastorage.bucket import SCSBucket [as 别名]
# 或者: from sinastorage.bucket.SCSBucket import put_bucket [as 别名]
 def test_get_bucket_meta(self):
     scs = SCSBucket(self.bucket_name)
     try:
         scs.put_bucket('public-read-write')
     except:
         self.fail('create bucket:%s is failed'%self.bucket_name)
           
     metaResult = scs.meta()
     self.assertTrue(ACL.ACL_GROUP_ANONYMOUSE in metaResult['ACL'], 'The bucket:%s acl dose not contains GRPS000000ANONYMOUSE group'%self.bucket_name)
     self.assertTrue(ACL.ACL_READ in metaResult['ACL'][ACL.ACL_GROUP_ANONYMOUSE], 'The bucket:%s acl GRPS000000ANONYMOUSE group hasn\'t read right'%self.bucket_name)
     self.assertTrue(ACL.ACL_WRITE in metaResult['ACL'][ACL.ACL_GROUP_ANONYMOUSE], 'The bucket:%s acl GRPS000000ANONYMOUSE group hasn\'t write right'%self.bucket_name)
       
     self.assertEqual(self.bucket_name, metaResult['Project'], 'The metaResult[\'Project\'] is not equal %s'%self.bucket_name)
     self.assertTrue(metaResult['Owner'] is not None, 'The metaResult[\'Owner\'] is None')
     self.assertTrue(metaResult['Last-Modified'] is not None, 'The metaResult[\'Last-Modified\'] is None')
开发者ID:SinaCloudStorage,项目名称:SinaStorage-SDK-Python,代码行数:17,代码来源:test.py

示例10: test_file_acl_info

# 需要导入模块: from sinastorage.bucket import SCSBucket [as 别名]
# 或者: from sinastorage.bucket.SCSBucket import put_bucket [as 别名]
 def test_file_acl_info(self):
     scs = SCSBucket(self.bucket_name)
     try:
         scs.put_bucket('public-read-write')
     except:
         self.fail('create bucket:%s is failed'%self.bucket_name)
     content = u'this is a file content text!!'
     canned_acl = 'public-read-write'                #快捷ACL
     scs.put(key=self.object_key, data=content, acl=canned_acl)
       
     #acl
     file_aclInfo = scs.acl_info(self.object_key)
     self.assertTrue(ACL.ACL_GROUP_ANONYMOUSE in file_aclInfo['ACL'], 'The acl dose not contains GRPS000000ANONYMOUSE group')
     self.assertTrue(ACL.ACL_READ in file_aclInfo['ACL'][ACL.ACL_GROUP_ANONYMOUSE], 'The acl GRPS000000ANONYMOUSE group hasn\'t read right')
     self.assertTrue(ACL.ACL_WRITE in file_aclInfo['ACL'][ACL.ACL_GROUP_ANONYMOUSE], 'The acl GRPS000000ANONYMOUSE group hasn\'t write right')
开发者ID:SinaCloudStorage,项目名称:SinaStorage-SDK-Python,代码行数:17,代码来源:test.py

示例11: test_make_url_authed

# 需要导入模块: from sinastorage.bucket import SCSBucket [as 别名]
# 或者: from sinastorage.bucket.SCSBucket import put_bucket [as 别名]
    def test_make_url_authed(self):
        scs = SCSBucket(self.bucket_name)
        try:
            scs.put_bucket('private')
        except:
            self.fail('create bucket:%s is failed'%self.bucket_name)
        content = u'this is a file content text!!'
        canned_acl = 'private'                #快捷ACL
        scs.put(key=self.object_key, data=content, acl=canned_acl)
         
        url = scs.make_url_authed(key=self.object_key,expire=datetime.timedelta(minutes=5))
        #下载文件
#         import urllib2
#         response = urllib2.urlopen(url)
        from sinastorage.compat import urllib
        response = urllib.request.urlopen(url)
        self.assertEqual(len(content), int(response.info()['Content-Length']), 'The response header Content-Length is not match')
开发者ID:SinaCloudStorage,项目名称:SinaStorage-SDK-Python,代码行数:19,代码来源:test.py

示例12: test_put_file

# 需要导入模块: from sinastorage.bucket import SCSBucket [as 别名]
# 或者: from sinastorage.bucket.SCSBucket import put_bucket [as 别名]
    def test_put_file(self):
        scs = SCSBucket(self.bucket_name)
        try:
            scs.put_bucket('public-read-write')
        except:
            self.fail('create bucket:%s is failed'%self.bucket_name)
              
        canned_acl = 'public-read-write'                #快捷ACL
        metadata = {}                                   #自定义文件属性信息
        metadata['author'] = 'dage'
        metadata['home'] = 'tianjin'
        metadata['age'] = '18'
        mimetype = 'text/plain'
          
        scs.putFile(key=self.object_key, filePath=self.local_file_name, acl=canned_acl
                    , metadata=metadata, mimetype=mimetype)
  
        scsResponse = scs.get(self.object_key)
        CHUNK = 16 * 1024
        file_content = ''
        from sinastorage.vendored import six
        while True:
            chunk = scsResponse.read(CHUNK)
            if not chunk: break
            if isinstance(chunk, six.text_type):
                file_content += chunk
            else:
                file_content += chunk.decode("utf-8")
        #assert file_content
#         self.assertEqual(content, file_content, 'The uploaded file content is not metch local.%s'%file_content)
        #assert metadata
        self.assertEqual(metadata['author'], scsResponse.responseHeaders['x-amz-meta-author'], 'The response metadata[\'author\'] is not match')
        self.assertEqual(metadata['home'], scsResponse.responseHeaders['x-amz-meta-home'], 'The response metadata[\'home\'] is not match')
        self.assertEqual(metadata['age'], scsResponse.responseHeaders['x-amz-meta-age'], 'The response metadata[\'age\'] is not match')
        #assert content-type
        self.assertEqual(mimetype, scsResponse.responseHeaders['content-type'], 'The response content-type is not match')
        #assert acl
        aclResult = scs.acl_info(self.object_key)
        self.assertTrue(ACL.ACL_GROUP_ANONYMOUSE in aclResult['ACL'], 'The acl dose not contains GRPS000000ANONYMOUSE group')
        self.assertTrue(ACL.ACL_READ in aclResult['ACL'][ACL.ACL_GROUP_ANONYMOUSE], 'The acl GRPS000000ANONYMOUSE group hasn\'t read right')
        self.assertTrue(ACL.ACL_WRITE in aclResult['ACL'][ACL.ACL_GROUP_ANONYMOUSE], 'The acl GRPS000000ANONYMOUSE group hasn\'t write right')
开发者ID:SinaCloudStorage,项目名称:SinaStorage-SDK-Python,代码行数:43,代码来源:test.py

示例13: test_get_file

# 需要导入模块: from sinastorage.bucket import SCSBucket [as 别名]
# 或者: from sinastorage.bucket.SCSBucket import put_bucket [as 别名]
 def test_get_file(self):
     scs = SCSBucket(self.bucket_name)
     try:
         scs.put_bucket('public-read-write')
     except:
         self.fail('create bucket:%s is failed'%self.bucket_name)
           
     scs.putFile(self.object_key, self.local_file_name)
       
     scsResponse = scs.get(self.object_key)
     CHUNK = 16 * 1024
     with open(self.local_file_name+'.downloaded', 'wb') as fp:
         while True:
             chunk = scsResponse.read(CHUNK)
             if not chunk: break
             fp.write(bytes(chunk) )
       
     import os
     self.assertTrue(os.path.exists(self.local_file_name+'.downloaded'), 'The download file dose not exists')
     self.assertEqual(str(os.stat(self.local_file_name).st_size), 
                      scsResponse.responseHeaders['content-length'], 'The download file size dose not match local file')
开发者ID:SinaCloudStorage,项目名称:SinaStorage-SDK-Python,代码行数:23,代码来源:test.py

示例14: test_put_content

# 需要导入模块: from sinastorage.bucket import SCSBucket [as 别名]
# 或者: from sinastorage.bucket.SCSBucket import put_bucket [as 别名]
   def test_put_content(self):
       scs = SCSBucket(self.bucket_name)
       try:
           scs.put_bucket('public-read-write')
       except:
           self.fail('create bucket:%s is failed'%self.bucket_name)
       content = u'this is a file content text!!'
       scs.put(self.object_key, content)
 
       scsResponse = scs.get(self.object_key)
       CHUNK = 16 * 1024
       file_content = ''
       from sinastorage.vendored import six
       while True:
           chunk = scsResponse.read(CHUNK)
           if not chunk: break
           if isinstance(chunk, six.text_type):
               file_content += chunk
           else:
               file_content += chunk.decode("utf-8")
       self.assertEqual(content, file_content, 'The uploaded file content is not match local.%s'%file_content)
开发者ID:SinaCloudStorage,项目名称:SinaStorage-SDK-Python,代码行数:23,代码来源:test.py

示例15: test_list_bucket_files

# 需要导入模块: from sinastorage.bucket import SCSBucket [as 别名]
# 或者: from sinastorage.bucket.SCSBucket import put_bucket [as 别名]
    def test_list_bucket_files(self):
        scs = SCSBucket(self.bucket_name)
        scs.put_bucket()
          
        content = u'this is a file content text!!'
        scs.put(self.object_key,content)
      
        file_gen = scs.listdir()
          
        self.assertTrue(file_gen is not None, 'List bucket files result is None')
        for item in file_gen:
            #(name, isPrefix, sha1, expiration_time, modify, owner, md5, content_type, size)
            self.assertTrue(item[0] is not None, 'file name is None')
            self.assertTrue(item[1] is not None, 'file isPrefix is None')
            self.assertTrue(item[2] is not None, 'file sha1 is None')
#             self.assertIsNotNone(item[3], 'file expiration_time is None')
            self.assertTrue(item[4] is not None, 'file modify is None')
            self.assertTrue(item[5] is not None, 'file owner is None')
            self.assertTrue(item[6] is not None, 'file md5 is None')
            self.assertTrue(item[7] is not None, 'file content_type is None')
            self.assertTrue(item[8] is not None, 'file size is None')
开发者ID:SinaCloudStorage,项目名称:SinaStorage-SDK-Python,代码行数:23,代码来源:test.py


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