tencentyun / cos-php-sdk-v5 Goto Github PK
View Code? Open in Web Editor NEWcos-php-sdk-v5
License: MIT License
cos-php-sdk-v5
License: MIT License
请问这个是否可以获取临时密匙?
PHP Warning: SimpleXMLElement::__construct(): Entity: line 4: parser error : Input is not proper UTF-8, indicate encoding !
Bytes: 0xB4 0xED 0xCE 0xF3 in /data/builds/vote.wj.qq.com/cos/vendor/qcloud/cos-sdk-v5/src/Qcloud/Cos/ExceptionParser.php on line 30
Warning: SimpleXMLElement::__construct(): Entity: line 4: parser error : Input is not proper UTF-8, indicate encoding !
Bytes: 0xB4 0xED 0xCE 0xF3 in /data/builds/vote.wj.qq.com/cos/vendor/qcloud/cos-sdk-v5/src/Qcloud/Cos/ExceptionParser.php on line 30
PHP Warning: SimpleXMLElement::__construct(): <TITLE>´£ºź̹ȫȳµōURL£©Ϟ·¨»/TITLE> in /data/builds/vote.wj.qq.com/cos/vendor/qcloud/cos-sdk-v5/src/Qcloud/Cos/ExceptionParser.php on line 30
JavaScript 都能自定义域名
看PHP的源码 也没有自定义域名
如图,上传图片,假如是jpg的,content-type应该是image/jpeg
,png图片应该是image/png
,gif应该是image/gif
,而不是全都是application/octet-stream
:
上传代码如下:
$cosClient = new Client([
'region' => $this->region,
'credentials' => [
'secretId' => $this->secretId,
'secretKey' => $this->secretKey,
],
]);
$fp = fopen($uploadFilePath, 'rb');
/** @var Result $retObj */
$retObj = $cosClient->Upload($this->bucket, $key, $fp);
is_resource($fp) && fclose($fp);
你已经是个成熟的sdk了,获取文件列表的时候增加几个参数来排序吧,比如按时间,文件大小等等,现在是名字吧
现在好像不支持数据万象的Pic-Operations
的 header支持,后续可否加上?
还是我没有找到在哪里加。。。
Extract_Phar,不加前缀,这样的类名,也是醉了!!!
Fatal error: Cannot redeclare class Extract_Phar in ../include/txsdk/cos-sdk-v5.phar on line 103
When you try to retrieve a non-exist object from an exists bucket, It should throw NoSuchKeyException
, not NoSuchBucketException
.
Test code:
$client = new Client(array(
'region' => 'gz',
'credentials' => array(
'appId' => '{appId}',
'secretId' => '{secretId}',
'secretKey' => '{secretKey}'
)
));
try {
$result = $client->headObject(array(
'Bucket' => '{exists bucket}',
'Key' => '{non-exists key}'
));
print_r($result);
} catch ( NoSuchKeyException $e ) {
echo 'No such key.';
} catch ( NoSuchBucketException $e) {
echo 'No such bucket.';
}
The output will be "No such bucket."
symfony/event-dispatcher suggests installing symfony/dependency-injection ()
symfony/event-dispatcher suggests installing symfony/http-kernel ()
guzzle/guzzle suggests installing guzzlehttp/guzzle (Guzzle 5 has moved to a new package name. The package you have installed, Guzzle 3, is deprecated.)
Package guzzle/guzzle is abandoned, you should avoid using it. Use guzzlehttp/guzzle instead.
Qcloud\Cos\Client::__construct()里面request.options应该把proxy参数默认也带进去,不然这配置代理的话很麻烦。
一些虚拟主机的php版本最高才5.4
array(2) {
["*structure"] => NULL
["*data"] => array(10) {
["Expiration"] => string(0) ""
["ETag"] => string(34) ""27685a34a98914d218329a9136cd777d""
["ServerSideEncryption"] => string(0) ""
["VersionId"] => string(0) ""
["SSECustomerAlgorithm"] => string(0) ""
["SSECustomerKeyMD5"] => string(0) ""
["SSEKMSKeyId"] => string(0) ""
["RequestCharged"] => string(0) ""
["RequestId"] => string(40) "NWI5OGU2NjRfMmI5ZDA4MDlfMWNlZl82NTIyOWM="
["ObjectURL"] => string(117) "http://csfc-test-1256260708.cos.ap-shanghai.myqcloud.com//uploads/20180912/27685a34a98914d218329a9136cd777d.png"
}
}
为何返回回来的data前面有*
IDE 提示 guzzle/guzzle 过期了,是不是可以更新到新的包guzzlehttp/guzzle
Package guzzle/guzzle is abandoned, you should avoid using it. Use guzzlehttp/guzzle instead.
接口名称 :
对象存储 listObjects 获取文件列表
问题描述:
请求api 列出文件列表。可以使用 NextMarker 来请求下一页数据,,如果我要请求 上一页 数据,,如果操作?
我bucket开启了私有读,这个生成的地址不能用,有文档我可以参考下吗
看你写的文档感觉技术也是不过关哈哈
Package operations: 2 installs, 0 updates, 0 removals
@moria @yaozongyou @yishuiliunian @puterjam @konakonall
调试接口的时候,莫名奇妙的多了下面一行字符,这些是无用的输出,会影响接口的使用,如果会可以去掉,请注释掉
Guzzle\Common\Collection Object ( [data:protected] => Array ( [min_part_size] => 5242880 [params] => Array ( ) ) )
代码位置:qcloud\cos-sdk-v5\src\Qcloud\Cos\Client.php 第103行 print_r($options);
public function createAuthorization( RequestInterface $request, $expires = '+30 minutes' ) { 。。。 foreach ( explode( '&', $request->getUri()->getQuery() ) as $query ) { if (!empty($query)) { $tmpquery = explode( '=', $query ); $key = strtolower( urlencode( $tmpquery[0] ) ); if (count($tmpquery) >= 2) { $value = urlencode( $tmpquery[1] ); } else { $value = ""; } $urlParamListArray[$key] = $key. '='. $value; } } 。。。 }
$request->getUri()->getQuery()
和
urlencode( $tmpquery[1] )
会两次urlencode,造成签名失败
"Expiration": "",
"ETag": "\"19f6bc7c91552d33161c246c4f67be92\"",
"ServerSideEncryption": "",
"VersionId": "",
"SSECustomerAlgorithm": "",
"SSECustomerKeyMD5": "",
"SSEKMSKeyId": "",
"RequestCharged": "",
"RequestId": "NWE0ZTM1N2FfYzZhMzNiMGFfNGYzYV9jMmYyMg==",
"ObjectURL": "http://timelang-1253895285.cos.ap-guangzhou.myqcloud.com/cms%2Fuploadfile%2F201801%2Fd966ce5359.png"
}
我用java的sdk可以取到带cdn 加速域名的文件url
php的怎么改?
之前提过一个issue,因为guzzle/guzzle已经弃用,建议换成新版本:guzzlehttp/guzzle,等了好久,终于换了,但也只是换了包,调用方法却没换,导致报错:
composer 的包 你确定能使用deleteObject?你确定如官方文档一样使用 deleteObject ?你是用肛门来想问题吗和写代码吗?
当BUCKET名称存在-
时,例如example-bucket
,会导致copy方法出错。
下载的是最新release版 release v1.1.4
cos-php-sdk-v5-1.1.4
报错:
Qcloud\Cos\Exception\ServiceResponseException: Cos Error Code: InvalidAccessKeyId, Status Code: 403, Cos Request ID: NWFkZWIwY2VfMjRiMjU4NjRfNmYzZV83N2JkNw==, Cos Error Type: client, Cos Error Message: The Access Key Id you provided does not exist in our records
求助!第一次使用相信腾讯的实力!不应该这样!ps:我用的COS是官方提供的免费体验COS API秘钥也配置过配置如图!马上需要使用COS预先测试下!
眼没花的话应该是没找到delete object和delete multiple object这两个接口的
PHP版本 7.1
上传COS文件代码
$result = $this->cosClient->Upload(
$bucket = $bucketName,
$key = $KeyForUpload,
$body = $file
);
将qcloud/cos-sdk-v5版本从1.3.2升级成为1.3.4,由于该SDK依赖的guzzle包升级成为guzzlehttp导致返回的 $result变量的值发生了改变,$result["Location"] 取值不存在,无法获取COS文件的URL地址,希望作者在升级版本时标注一下版本改动情况
具体如下:
文件:qcloud\cos-sdk-v5\src\Qcloud\Cos\Client.php
public function upload($bucket, $key, $body, $options = array()) {
$body = EntityBody::factory($body);
$options = Collection::fromConfig(array_change_key_case($options), array(
'min_part_size' => MultipartUpload::MIN_PART_SIZE,
'params' => $options));
print_r($options);
if ($body->getSize() < $options['min_part_size']) {
// Perform a simple PutObject operation
return $this->putObject(array(
'Bucket' => $bucket,
'Key' => $key,
'Body' => $body,
) + $options['params']);
}
第103 行 居然还有一个print_r ....
这应该怎么弄?
Undefined variable: bodyParameter
Undefined variable: bodyParameter
Undefined variable: bodyParameter
调用程序之后,请求的地址是:http://sytushu-1255313017.cos..myqcloud.com/5b1a128e2b041.jpg,cos
和myqcloud
之间有2个点号,获取不到设置的region信息。配置的是:sh。
Package guzzle/guzzle is abandoned, you should avoid using it. Use guzzlehttp/guzzle instead.
Hi Team,
I am using this plugin from last 1 month. Everything was fine ( uploading images ). But from yesterday onwards I am getting this issue " your policy or acl has reached the limit " in Qcloud\Cos\Exception\ServiceResponseException.
Due to this I am unable upload any images to cloud..
Can you please help me out
Thanks in advance!!!!
发了工单告诉我PHP最大只支持60M的上传速度,说是其他语言可以支持并发上传,那么请问PHP如何跑满内网带宽呢?
版本:v1.3.4
文件:/src/Qcloud/Cos/UploadBodyMiddleware.php
运行报错:Call to a member function signRequest() on null
看了下代码,好像是这个地方:
public function __invoke(RequestInterface $request, array $options) {
$fn = $this->nextHandler;
return $fn($this->signature->signRequest($request), $options);
}
是不是$this->signature没有进行初始化,v1.3.3是正常得,v1.3.4会报错。
用过Wampserver
和一个服务器空间, 运行自带的测试例子会有这个错误
现在 Services 里没有看到这个方法。
Hi Team,
Can you please help me out
Thanks in advance
==================== Debug output of model ===================== Model data ----------- This data can be retrieved from the model object using the get() method of the model (e.g. $model->get($key)) or accessing the model like an associative array (e.g. $model['key']). [Expiration] => [ETag] => "67b55d5c51dfa185bc8360701975e36f" [ServerSideEncryption] => [VersionId] => [SSECustomerAlgorithm] => [SSECustomerKeyMD5] => [SSEKMSKeyId] => [RequestCharged] => [RequestId] => NWE0ZTM3ODdfMWJiMjk0MGFfYjMxYV9jMmNjNg== [ObjectURL] => http://timelang-1253895285.cos.ap-guangzhou.myqcloud.com/cms%2Fuploadfile%2F201801%2F38b2b23111.png
函数命名有的蛇形有的驼峰,甚至有的首字母大写,还跟文档对应不起来,完全取消了使用的想法,这么大的个公司
怎么使用万象优图的图片样式, getObjectUrl 方法返回的url, 手动拼接样式名称不好使
提示 guzzlehttp/guzzle 版本必须是 7.0.1,麻烦更新一下 composer.json 文件
你好,我的bucket设置了自定义域名,请问怎样能获得自定义域名下的预签名链接?
谢谢!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.