├── README.md ├── aws.php ├── curl.php ├── qiniu.php ├── tencent.php ├── test.php ├── ucloud.php └── wangyi.php /README.md: -------------------------------------------------------------------------------- 1 | 使用方法请参考test.php 2 | 3 | 其他细节请参考官方api,有疑问请留言。 4 | 5 | 网易:https://www.163yun.com/help/documents/15587955050311680 6 | 7 | 腾讯:https://cloud.tencent.com/document/product/436/7751 8 | 9 | 七牛:https://developer.qiniu.com/kodo/api/1731/api-overview 10 | 11 | UCloud:https://docs.ucloud.cn/api/ufile-api/index 12 | 13 | 七牛云免费10G空间,每月免费20G流量,通过下面邀请链接申请七牛云可以给我增加每月5G流量,谢谢。 14 | https://portal.qiniu.com/signup?code=3lcny6zgo60ya 15 | -------------------------------------------------------------------------------- /aws.php: -------------------------------------------------------------------------------- 1 | $bucket, 23 | 'deadline' => time() + 3600 24 | )); 25 | 26 | $hash = hash_hmac( 27 | 'sha1', 28 | qn_base64_encode($options), 29 | $accessKeySecret, 30 | true 31 | ); 32 | $auth = $accessKeyId . ':' . qn_base64_encode($hash) . ':' . qn_base64_encode($options); 33 | 34 | $headers = array( 35 | 'Content-Type: multipart/form-data' 36 | ); 37 | 38 | $postfileds = array( 39 | 'token' => $auth, 40 | 'key' => $filename, 41 | 'file' => new CURLFile($filepath) 42 | ); 43 | 44 | return curl($url, $headers, 'POST', '', $postfileds); 45 | } 46 | function 七牛对象存储删除 ($filename) { 47 | $accessKeyId = QINIU_ACCESSKEYID; 48 | $accessKeySecret = QINIU_ACCESSKEYSECRET; 49 | $bucket = QINIU_BUCKET; 50 | 51 | $options = '/delete/' . qn_base64_encode($bucket . ':' . $filename); 52 | 53 | $url = QINIU_RS_HOST . $options; 54 | 55 | $hash = hash_hmac( 56 | 'sha1', 57 | $options . "\n", 58 | $accessKeySecret, 59 | true 60 | ); 61 | $auth = $accessKeyId . ':' . qn_base64_encode($hash); 62 | 63 | $headers = array( 64 | "Authorization: QBox $auth" 65 | ); 66 | 67 | return curl($url, $headers, 'POST'); 68 | } 69 | function 七牛对象存储列表 ($query = '') { 70 | $accessKeyId = QINIU_ACCESSKEYID; 71 | $accessKeySecret = QINIU_ACCESSKEYSECRET; 72 | $bucket = QINIU_BUCKET; 73 | 74 | $options = "/list?bucket=$bucket$query"; 75 | 76 | $url = QINIU_RSF_HOST . $options; 77 | 78 | $hash = hash_hmac( 79 | 'sha1', 80 | $options . "\n", 81 | $accessKeySecret, 82 | true 83 | ); 84 | $auth = $accessKeyId . ':' . qn_base64_encode($hash); 85 | 86 | $headers = array( 87 | "Authorization: QBox $auth" 88 | ); 89 | 90 | $jsonlist = curl($url, $headers, 'GET'); 91 | $objectlist = json_decode($jsonlist); 92 | if (isset($objectlist->marker)) { 93 | $objectlist->NextMarker = $objectlist->marker; unset($objectlist->marker); 94 | } else { 95 | $objectlist->NextMarker = ''; 96 | } 97 | $objectlist->Contents = $objectlist->items; unset($objectlist->items); 98 | return $objectlist; 99 | } -------------------------------------------------------------------------------- /tencent.php: -------------------------------------------------------------------------------- 1 | 'sha1', 48 | 'q-ak' => $accessKeyId, 49 | 'q-sign-time' => $signTime, 50 | 'q-key-time' => $signTime, 51 | 'q-header-list' => 'host', 52 | 'q-url-param-list' => '', 53 | 'q-signature' => $hash 54 | ))); 55 | $headers = array( 56 | "Authorization: $auth" 57 | ); 58 | 59 | if ($file) { 60 | return curl($url, $headers, $method, $filepath); 61 | } else { 62 | return curl($url, $headers, $method); 63 | } 64 | } 65 | function 腾讯对象存储上传 ($filename, $filepath) { 66 | return 腾讯对象存储('PUT', $filename, $filepath); 67 | } 68 | function 腾讯对象存储删除 ($filename) { 69 | return 腾讯对象存储('DELETE', $filename); 70 | } 71 | function 腾讯对象存储列表 ($query = '') { 72 | $xmllist = 腾讯对象存储('GET', '', '', $query); 73 | $objectlist = simplexml_load_string($xmllist, 'SimpleXMLElement', LIBXML_NOCDATA); 74 | return $objectlist; 75 | } -------------------------------------------------------------------------------- /test.php: -------------------------------------------------------------------------------- 1 | Contents = $objectlist->DataSet; unset($objectlist->DataSet); 62 | return $objectlist; 63 | } -------------------------------------------------------------------------------- /wangyi.php: -------------------------------------------------------------------------------- 1 |