登陆

阿里云oss存储中的yourSecurityToken是什么token呀,查了文档没找到

// 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录  创建RAM账号。$accessKeyId = "<yourAccessKeyId>";
$accessKeySecret = "<yourAccessKeySecret>";// Endpoint以杭州为例,其它Region请按实际情况填写。$endpoint = "url";
$bucket= "<yourBucketName>";
$object = "<yourObjectName>";
$securityToken = "<yourSecurityToken>";// 设置URL的有效期为3600秒。$timeout = 3600;try {
   $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false, $securityToken);    // 生成GetObject的签名URL。
   $signedUrl = $ossClient->signUrl($bucket, $object, $timeout);
} catch (OssException $e) {
   printf(__FUNCTION__ . ": FAILED\n");
   printf($e->getMessage() . "\n");    return;
}print(__FUNCTION__ . ": signedUrl: " . $signedUrl . "\n");// 可以使用代码来访问签名的URL,也可以输入到浏览器中进行访问。$request = new RequestCore($signedUrl);// 生成的URL默认以GET方式访问。$request->set_method('GET');
$request->add_header('Content-Type', '');
$request->send_request();
$res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code());if ($res->isOK()) {    print(__FUNCTION__ . ": OK" . "\n");
} else {    print(__FUNCTION__ . ": FAILED" . "\n");
};

# PHP
Life注定不平凡Life注定不平凡36 天前195 次浏览

全部回复(0)我要回复

暂无评论~
  • 取消回复发送