Coder Social home page Coder Social logo

qcloud-cos-client's Issues

真实环境测试 API

ServiceClient

  • $service->getBuckets();
  • $service->getBuckets('ap-guangzhou');

JobClient

  • $job->getJobs(array $query = []);
  • $job->createJob(array $body);
  • $job->describeJob(string $id);
  • $job->updateJobPriority(string $id, int $priority);
  • $job->updateJobStatus(string $id, array $query);

BucketClient

  • $bucket->putBucket(array $body);
  • $bucket->headBucket();
  • $bucket->deleteBucket();
  • $bucket->getObjects(array $query = []);
  • $bucket->getObjectVersions(array $query = []);

Versions

  • $bucket->putVersions(array $body);
  • $bucket->getVersions();

ACL

  • $bucket->putACL(array $body, array $headers = [])
  • $bucket->getACL();

CORS

  • $bucket->putCORS(array $body);
  • $bucket->getCORS();
  • $bucket->deleteCORS();

Lifecycle

  • $bucket->putLifecycle(array $body);
  • $bucket->getLifecycle();
  • $bucket->deleteLifecycle();

Policy

  • $bucket->putPolicy(array $body);
  • $bucket->getPolicy();
  • $bucket->deletePolicy();

Referer

  • $bucket->putReferer(array $body);
  • $bucket->getReferer();

Taging

  • $bucket->putTaging(array $body);
  • $bucket->getTaging();
  • $bucket->deleteTaging();

Website

  • $bucket->putWebsite(array $body);
  • $bucket->getWebsite();
  • $bucket->deleteWebsite();

Inventory

  • $bucket->putInventory(string $id, array $body)
  • $bucket->getInventory(string $id)
  • $bucket->getInventoryConfigurations(?string $nextContinuationToken = null)
  • $bucket->deleteInventory(string $id)

Versioning

  • $bucket->putVersioning(array $body);
  • $bucket->getVersioning();

Replication

  • $bucket->putReplication(array $body);
  • $bucket->getReplication();
  • $bucket->deleteReplication();

Logging

  • $bucket->putLogging(array $body);
  • $bucket->getLogging();

Accelerate

  • $bucket->putAccelerate(array $body);
  • $bucket->getAccelerate();

Encryption

  • $bucket->putEncryption(array $body);
  • $bucket->getEncryption();
  • $bucket->deleteEncryption();

ObjectClient

Object

  • $bucket->putObject(string $key, string $body, array $headers = []);
  • $bucket->copyObject(string $key, array $headers = []);
  • $bucket->getObject(string $key, array $query = [], array $headers = []);
  • $bucket->headObject(string $key, string $versionId, array $headers = []);
  • $bucket->restoreObject(string $key, string $versionId, array $body);
  • $bucket->selectObjectContents(string $key, array $body);
  • $bucket->deleteObject(string $key, string $versionId);
  • $bucket->deleteObjects(array $body);

Object ACL

  • $bucket->putObjectACL(string $key, array $body, array $headers = []);
  • $bucket->getObjectACL(string $key);

Object Tagging

  • $bucket->putObjectTagging(string $key, string $versionId, array $body);
  • $bucket->getObjectTagging(string $key, string $versionId);
  • $bucket->deleteObjectTagging(string $key, string $versionId);

Object partial upload

  • $bucket->createUploadId(string $key, array $headers = []);
  • $bucket->uploadPart(string $key, int $partNumber, string $uploadId, string $body, array $headers = []);
  • $bucket->copyPart(string $key, int $partNumber, string $uploadId, array $headers = []);
  • $bucket->markUploadAsCompleted(string $key, string $uploadId, array $body);
  • $bucket->markUploadAsAborted(string $key, string $uploadId);
  • $bucket->getUploadJobs(array $query = []);
  • $bucket->getUploadedParts(string $key, string $uploadId, array $query = []);

PUT Object acl 接口 400 bad Request

接口:

Overtrue\CosClient\ObjectClient -> putObjectACL()

调用方法:

$client->putObjectACL($path,[],["x-cos-acl" => "public-read"])

抛出异常

Overtrue\CosClient\Exceptions\ClientException : Client error: `PUT https://x.cos.ap-guangzhou.myqcloud.com/x.jpg?acl=` resulted in a `400 Bad Request` response:
<?xml version='1.0' encoding='utf-8' ?>
<Error>
<Code>InvalidArgument</Code>
<Message>AccessControlPolicy is not well- (truncated...)

发送的数据:
打印 Overtrue\CosClient\ObjectClient 第 95 行的第二个参数得到:

[ // vendor/overtrue/qcloud-cos-client/src/ObjectClient.php:186
  "query" => array:1 [
    "acl" => ""
  ]
  "body" => "<xml/>"
  "headers" => array:1 [
    "x-cos-acl" => "public-read"
  ]
]

如果将 Overtrue\CosClient\Support\XML::fromArray(array $data):bool|string 方法重写为:

    public static function fromArray(array $data): bool|string
    {
        if (empty($data)) return '';
        return Transformer::toXml($data);
    }

Overtrue\CosClient\ObjectClient 第 95 行的第二个参数得到:

 [ // vendor/overtrue/qcloud-cos-client/src/ObjectClient.php:186
  "query" => array:1 [
    "acl" => ""
  ]
  "body" => ""
  "headers" => array:1 [
    "x-cos-acl" => "public-read"
  ]
]

则接口调用成功

Error On ExpireTime

when i update to new version , file uploading has exception error:

Overtrue\CosClient\Signature::getTimeSegments(): Argument #1 ($expires) must be of type DateTimeInterface|string|int, null given, called in /var/www/html/vendor/overtrue/qcloud-cos-client/src/Signature.php on line 26

as i checked $expires variable is null and when i set value for $expires to int like 10 , it will work.

custom domain will cause signature wrong.

When using custom domain, current signature will contain custom domain host, it will cause tencent cloud api return "403 Forbiddden".
So in Class Signature, maybe __construct should contain parameters like bucket, app_id, region, and in getHeadersToBeSigned should replace host part to prevent error, like

    protected static function getHeadersToBeSigned(RequestInterface $request): array
    {
        $headers = [];
        foreach ($request->getHeaders() as $header => $value) {
            $header = strtolower(urlencode($header));

            if (str_contains($header, 'x-cos-') || \in_array($header, self::SIGN_HEADERS)) {
                if ($header == 'host') {
                    $value[0] = \sprintf(
                        '%s-%s.cos.%s.myqcloud.com',
                        $this->bucket,
                        $this->app_id,
                        $this->region
                    );
                }
                $headers[$header] = $value[0];
            }
        }

        ksort($headers);

        return $headers;
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.