1 | <?php |
||
5 | class Auth |
||
6 | { |
||
7 | const AUTH_URL_FORMAT_ERROR = -1; |
||
8 | const AUTH_SECRET_ID_KEY_ERROR = -2; |
||
9 | |||
10 | /** |
||
11 | * 生成多次有效签名函数(用于上传和下载资源,有效期内可重复对不同资源使用). |
||
12 | * |
||
13 | * @param int $expired 过期时间,unix时间戳 |
||
14 | * @param string $bucketName 文件所在bucket |
||
15 | * |
||
16 | * @return string 签名 |
||
17 | */ |
||
18 | 10 | public static function appSign($expired, $bucketName) |
|
30 | |||
31 | /** |
||
32 | * 生成单次有效签名函数(用于删除和更新指定fileId资源,使用一次即失效). |
||
33 | * |
||
34 | * @param string $bucketName 文件所在bucket |
||
35 | * @param string $path |
||
36 | * |
||
37 | * @return string 签名 |
||
38 | */ |
||
39 | 4 | public static function appSign_once($path, $bucketName) |
|
56 | |||
57 | /** |
||
58 | * 生成绑定资源的多次有效签名. |
||
59 | * |
||
60 | * @param string $path 文件相对bucket的路径 /test/test.log 标识该bucket下test目录下的test.log文件 |
||
61 | * @param string $bucketName bucket |
||
62 | * @param int $expired 过期时间,unix时间戳 |
||
63 | * |
||
64 | * @return string 签名串 |
||
65 | */ |
||
66 | public static function appSign_multiple($path, $bucketName, $expired) |
||
83 | |||
84 | /** |
||
85 | * 签名函数(上传、下载会生成多次有效签名,删除资源会生成单次有效签名). |
||
86 | * |
||
87 | * @param string $appId |
||
88 | * @param string $secretId |
||
89 | * @param string $secretKey |
||
90 | * @param int $expired 过期时间,unix时间戳 |
||
91 | * @param string $fileId 文件路径,以 /{$appId}/{$bucketName} 开头 |
||
92 | * @param string $bucketName 文件所在bucket |
||
93 | * |
||
94 | * @return string 签名 |
||
95 | */ |
||
96 | 14 | private static function appSignBase($appId, $secretId, $secretKey, $expired, $fileId, $bucketName) |
|
112 | } |
||
113 | |||
115 |