createMultipartUpload.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. require dirname(__FILE__) . '/../vendor/autoload.php';
  3. $secretId = "COS_SECRETID"; //"云 API 密钥 SecretId";
  4. $secretKey = "COS_SECRETKEY"; //"云 API 密钥 SecretKey";
  5. $region = "ap-beijing"; //设置一个默认的存储桶地域
  6. $cosClient = new Qcloud\Cos\Client(
  7. array(
  8. 'region' => $region,
  9. 'schema' => 'https', //协议头部,默认为http
  10. 'credentials'=> array(
  11. 'secretId' => $secretId ,
  12. 'secretKey' => $secretKey)));
  13. try {
  14. $result = $cosClient->createMultipartUpload(array(
  15. 'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
  16. 'Key' => 'exampleobject',
  17. /*
  18. 'CacheControl' => 'string',
  19. 'ContentDisposition' => 'string',
  20. 'ContentEncoding' => 'string',
  21. 'ContentLanguage' => 'string',
  22. 'ContentLength' => integer,
  23. 'ContentType' => 'string',
  24. 'Expires' => 'string',
  25. 'Metadata' => array(
  26. 'string' => 'string',
  27. ),
  28. 'StorageClass' => 'string'
  29. */
  30. ));
  31. // 请求成功
  32. print_r($result);
  33. } catch (\Exception $e) {
  34. // 请求失败
  35. echo($e);
  36. }