php 腾讯云 对象存储V5版本 获取返回的上传文件的链接方法
2023-09-14 08:56:56 时间
腾讯云 对象存储V5版本 文档地址:https://github.com/tencentyun/cos-php-sdk-v5
调用简单文件上传方法:
返回数据如下
Array ( [data:protected] => Array ( [Expiration] => [ETag] => "ed076287532e86365e841e92bfc50d8c" [ServerSideEncryption] => AES256 [VersionId] => [SSECustomerAlgorithm] => [SSECustomerKeyMD5] => [SSEKMSKeyId] => [RequestCharged] => [RequestId] => NWE3Yzg0M2NfOTcyMjViNjRfYTE1YV8xNTQzYTY= [ObjectURL] => http://testbucket-1252448703.cos.cn-south.myqcloud.com/11%2F%2F32%2F%2F43 ) )
获取返回数据中 ObjectURL 参数的值得方法如下
上传本地文件 #putObject try { $result = $cosClient->putObject(array( //bucket的命名规则为{name}-{appid} ,此处填写的存储桶名称必须为此格式 'Bucket' => 'testbucket-125000000', 'Key' => 'string', 'Body' => fopen('./hello.txt', 'rb'), 'CacheControl' => 'string', 'ContentDisposition' => 'string', 'ContentEncoding' => 'string', 'ContentLanguage' => 'string', 'ContentLength' => integer, 'ContentType' => 'string', 'Expires' => 'mixed type: string (date format)|int (unix timestamp)|\DateTime', 'GrantFullControl' => 'string', 'GrantRead' => 'string', 'GrantWrite' => 'string', 'Metadata' => array( 'string' => 'string', ), 'StorageClass' => 'string', )); print_r($result); print_r(urldecode($result->get('ObjectURL'))); } catch (\Exception $e) { echo "$e\n"; }
获取返回的url链接的代码为:
print_r(urldecode($result->get('ObjectURL')));
如若使用的是文件流方式上传,获取返回的url链接代码为:print_r(urldecode($result->get('Location')));
简单文件上传
相关文章
- PHP上传文件
- 【转】PHP网站(nginx、php-fpm、mysql) 用户权限解析
- PHP如何自动识别第三方Restful API的内容,自动渲染成 json、xml、html、serialize、csv、php等数据
- PHP安装模式cgi、fastcgi、php_mod比较
- PHP文件上传至另一台服务器
- 用PHP的fopen函数读写robots.txt文件
- php file_get_contents计时读取一个文件/页面 防止读取不到内容
- dns未设置 PHP Warning: file_get_contents():php_network_getaddresses: getaddrinfo failed:
- PHP fastcgi模式大文件上传500错误
- php会话全揭秘
- rsa互通密钥对生成及互通加解密(c#,java,php)
- php/nginx/axios: 文件上传: 配置最长执行时间等相关项 (php8.1.1 / nginx 1.18.0 / vue@3.2.26 )
- PHP输出xls文件
- PHP文件操作[总结]
- 使用php模拟form上传文件
- PHP excel读取excel文件转换为数组
- [php-src] Php扩展的多文件编译
- [php-src]一个Php扩展的结构
- [转]考虑 PHP 5.0~5.6 各版本兼容性的 cURL 文件上传
- Atitit 文件上传 架构设计 实现机制 解决方案 实践java php c#.net js javascript c++ python
- PHP面试题:php读取文件内容的几种方法和函数?
- Redis使用示例及在PHP环境中用redis存储session
- post 和php://input 转