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


Python SCSBucket.update_acl方法代码示例

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


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

示例1: test_update_file_acl

# 需要导入模块: from sinastorage.bucket import SCSBucket [as 别名]
# 或者: from sinastorage.bucket.SCSBucket import update_acl [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

示例2: update_file_acl

# 需要导入模块: from sinastorage.bucket import SCSBucket [as 别名]
# 或者: from sinastorage.bucket.SCSBucket import update_acl [as 别名]
def update_file_acl():
    s = SCSBucket('test11')
    acl = {}
    acl[ACL.ACL_GROUP_ANONYMOUSE] = [ACL.ACL_READ]
    acl[ACL.ACL_GROUP_CANONICAL] = [ACL.ACL_READ_ACP,ACL.ACL_WRITE_ACP]
    
    s.update_acl('sss.txt', acl)
开发者ID:SinaCloudStorage,项目名称:SinaStorage-SDK-Python,代码行数:9,代码来源:sample.py

示例3: obj_upload

# 需要导入模块: from sinastorage.bucket import SCSBucket [as 别名]
# 或者: from sinastorage.bucket.SCSBucket import update_acl [as 别名]
def obj_upload(data, fileTag):

    """ Upload photo by object. """

    sinastorage.setDefaultAppInfo(API_KEY, API_SECRET)
    s = SCSBucket('sharephotos')
    path = time.ctime().replace(' ', '_')
    # if '/' in file name there will be problems
    filename = fileTag[:6] + '_' + path + '.jpg'  # use jpg temporary
    scs_response = s.put(filename, data)
    s.update_acl(filename, acl)
    url = s.make_url(filename)   # get url of image in the storage
    return url
开发者ID:RawEvan,项目名称:sharephotos,代码行数:15,代码来源:storage.py

示例4: url_upload

# 需要导入模块: from sinastorage.bucket import SCSBucket [as 别名]
# 或者: from sinastorage.bucket.SCSBucket import update_acl [as 别名]
def url_upload(imgSrc='http://www.w3school.com.cn/i/site_photoref.jpg'):

    """ Upload photo by url. """

    sinastorage.setDefaultAppInfo(API_KEY, API_SECRET)
    s = SCSBucket('sharephotos')
    data = urllib2.urlopen(imgSrc).read()
    path = imgSrc.split('/')[2] + '/%s__' % time.ctime()
    # if '/' in file name there will be problems
    filename = path + imgSrc.replace('/', '_')
    scs_response = s.put(filename, data)
    s.update_acl(filename, acl)
    url = s.make_url(filename)   # get url of image in the storage
    return url
开发者ID:RawEvan,项目名称:sharephotos,代码行数:16,代码来源:storage.py

示例5: storeImage

# 需要导入模块: from sinastorage.bucket import SCSBucket [as 别名]
# 或者: from sinastorage.bucket.SCSBucket import update_acl [as 别名]
def storeImage(imgSrc):
    sinastorage.setDefaultAppInfo("1cjfyo5kQPdnsI3cUc6W", "a3c139370a3509f269331930515729747573aa10")
    djBucket = SCSBucket("dj-images")  # not dj_images
    acl = {}  # Access control list
    acl[ACL.ACL_GROUP_ANONYMOUSE] = [ACL.ACL_READ]

    data = urllib2.urlopen(imgSrc).read()
    path = imgSrc.split("/")[2] + "/"
    # if '/' in file name there will be problems
    filename = path + imgSrc.replace("/", "@")
    scsResponse = djBucket.put(filename, data)  # upload the file
    stUrl = djBucket.make_url(filename)  # get url of image in the storage
    djBucket.update_acl(filename, acl)  # set acl for the file

    # save infomation to sql
    try:
        imgstorage.objects.get_or_create(original_url=imgSrc, storage_url=stUrl)
    except:
        print "insert into mysql error"
        pass  # solve this later

    return stUrl
开发者ID:AugustLONG,项目名称:images_spider,代码行数:24,代码来源:storage.py

示例6: run

# 需要导入模块: from sinastorage.bucket import SCSBucket [as 别名]
# 或者: from sinastorage.bucket.SCSBucket import update_acl [as 别名]
 def run(self):
     try:
         self.mutex.lock()
         self.state = RunnableState.RUNNING
         s = SCSBucket(self.bucketName)
         scsResponse = s.update_acl(self.key, self.acl)
         self.response =  scsResponse
     except SCSError, e:
         self.response = SCSResponse(e.urllib2Request, e.urllib2Response)
         self.response._responseBody = e.data
         self.state = RunnableState.DID_FAILED
         self.emitter.emit(QtCore.SIGNAL("UpdateFileACLDidFailed(PyQt_PyObject,PyQt_PyObject)"), self, e.msg)
         return
开发者ID:vfhky,项目名称:SCS_Client,代码行数:15,代码来源:Runnables.py


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