zoukankan      html  css  js  c++  java
  • php 腾讯云 对象存储V5版本 获取返回的上传文件的链接方法

    腾讯云 对象存储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
    ";
    }
    获取返回的url链接的代码为:
    print_r(urldecode($result->get('ObjectURL')));

    如若使用的是文件流方式上传,获取返回的url链接代码为:
    print_r(urldecode($result->get('Location')));


    简单文件上传

  • 相关阅读:
    mysql日期加减
    cron 配置计划任务的书写格式(quartz 时间配置)
    空值排序问题
    update 表名 set 字段=值,数据更新
    insert into 数据插入
    SQL里面的char类型
    SQL使用代码创建数据完整性,约束
    SQL制表
    sql创建数据库
    验证码
  • 原文地址:https://www.cnblogs.com/-mrl/p/8631274.html
Copyright © 2011-2022 走看看