src/base.js
function decodeAcl(AccessControlPolicy) {
    var result = {
        GrantFullControl: [],
        GrantWrite: [],
        GrantRead: [],
        GrantReadAcp: [],
        GrantWriteAcp: [],
        ACL: '',
    };
    var GrantMap = {
        'FULL_CONTROL': 'GrantFullControl',
        'WRITE': 'GrantWrite',
        'READ': 'GrantRead',
        'READ_ACP': 'GrantReadAcp',
        'WRITE_ACP': 'GrantWriteAcp',
    };
    var Grant = AccessControlPolicy.AccessControlList.Grant;
    if (Grant) {
        Grant = util.isArray(Grant) ? Grant : [Grant];
    }
    var PublicAcl = {READ: 0, WRITE: 0, FULL_CONTROL: 0};
    Grant.length && util.each(Grant, function (item) {
        if (item.Grantee.ID === 'qcs::cam::anyone:anyone' || item.Grantee.URI === 'http://cam.qcloud.com/groups/global/AllUsers') {
            PublicAcl[item.Permission] = 1;
        } else if (item.Grantee.ID !== AccessControlPolicy.Owner.ID) {
            result[GrantMap[item.Permission]].push('id="' + item.Grantee.ID + '"');
        }
    });
    if (PublicAcl.FULL_CONTROL || (PublicAcl.WRITE && PublicAcl.READ)) {
        result.ACL = 'public-read-write';
    } else if (PublicAcl.READ) {
        result.ACL = 'public-read';
    } else {
        result.ACL = 'private';
    }
    util.each(GrantMap, function (item) {
        result[item] = uniqGrant(result[item].join(','));
    });
    return result;
}
function decodeAcl(AccessControlPolicy) {
    var result = {
        GrantFullControl: [],
        GrantWrite: [],
        GrantRead: [],
        GrantReadAcp: [],
        GrantWriteAcp: [],
        ACL: '',
    };
    var GrantMap = {
        'FULL_CONTROL': 'GrantFullControl',
        'WRITE': 'GrantWrite',
        'READ': 'GrantRead',
        'READ_ACP': 'GrantReadAcp',
        'WRITE_ACP': 'GrantWriteAcp',
    };
    var Grant = AccessControlPolicy.AccessControlList.Grant;
    if (Grant) {
        Grant = util.isArray(Grant) ? Grant : [Grant];
    }
    var PublicAcl = {READ: 0, WRITE: 0, FULL_CONTROL: 0};
    Grant.length && util.each(Grant, function (item) {
        if (item.Grantee.ID === 'qcs::cam::anyone:anyone' || item.Grantee.URI === 'http://cam.qcloud.com/groups/global/AllUsers') {
            PublicAcl[item.Permission] = 1;
        } else if (item.Grantee.ID !== AccessControlPolicy.Owner.ID) {
            result[GrantMap[item.Permission]].push('id="' + item.Grantee.ID + '"');
        }
    });
    if (PublicAcl.FULL_CONTROL || (PublicAcl.WRITE && PublicAcl.READ)) {
        result.ACL = 'public-read-write';
    } else if (PublicAcl.READ) {
        result.ACL = 'public-read';
    } else {
        result.ACL = 'private';
    }
    util.each(GrantMap, function (item) {
        result[item] = uniqGrant(result[item].join(','));
    });
    return result;
}
function decodeAcl ( AccessControlPolicy ) { var result = { GrantFullControl : [ ] , GrantWrite : [ ] , GrantRead : [ ] , GrantReadAcp : [ ] , GrantWriteAcp : [ ] , ACL : '' , } ; var GrantMap = { 'FULL_CONTROL' : 'GrantFullControl' , 'WRITE' : 'GrantWrite' , 'READ' : 'GrantRead' , 'READ_ACP' : 'GrantReadAcp' , 'WRITE_ACP' : 'GrantWriteAcp' , } ; var Grant = AccessControlPolicy . AccessControlList . Grant ; if ( Grant ) { Grant = util . isArray ( Grant ) ? Grant : [ Grant ] ; } var PublicAcl = { READ : 0 , WRITE : 0 , FULL_CONTROL : 0 } ; Grant . length && util . each ( Grant , function ( item ) { if ( item . Grantee . ID === 'qcs::cam::anyone:anyone' || item . Grantee . URI === 'http://cam.qcloud.com/groups/global/AllUsers' ) { PublicAcl [ item . Permission ] = 1 ; } else if ( item . Grantee . ID !== AccessControlPolicy . Owner . ID ) { result [ GrantMap [ item . Permission ] ] . push ( 'id="' + item . Grantee . ID + '"' ) ; } } ) ; if ( PublicAcl . FULL_CONTROL || ( PublicAcl . WRITE && PublicAcl . READ ) ) { result . ACL = 'public-read-write' ; } else if ( PublicAcl . READ ) { result . ACL = 'public-read' ; } else { result . ACL = 'private' ; } util . each ( GrantMap , function ( item ) { result [ item ] = uniqGrant ( result [ item ] . join ( ',' ) ) ; } ) ; return result ; }
私有方法
私有方法