Home  >  Q&A  >  body text

What token is yourSecurityToken in Alibaba Cloud oss ​​storage? I checked the documentation and couldn’t find it.

// The Alibaba Cloud main account AccessKey has access rights to all APIs, and the risk is very high. It is strongly recommended that you create and use a RAM account for API access or daily operation and maintenance. Please log in to create a RAM account. $accessKeyId = "<yourAccessKeyId>";
$accessKeySecret = "<yourAccessKeySecret>";// The endpoint is Hangzhou as an example. For other regions, please fill in the actual situation. $endpoint = "url";
$bucket= "<yourBucketName>";
$object = "<yourObjectName>";
$securityToken = "<yourSecurityToken>";// Set URL The validity period is 3600 seconds. $timeout = 3600;try {
$ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false, $securityToken); // Generate the signature URL of GetObject.
$signedUrl = $ossClient->signUrl($bucket, $object, $timeout);
} catch (OssException $e) {
printf(__FUNCTION__ . ": FAILED\n");
printf($e->getMessage() . "\n"); return;
}print(__FUNCTION__ . ": signedUrl: " . $signedUrl . "\n");// You can use code to To access the signed URL, you can also enter it into the browser to access it. $request = new RequestCore($signedUrl);//The generated URL is accessed in GET mode by default. $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");
};

Life注定不平凡Life注定不平凡1913 days ago2032

reply all(0)I'll reply

No reply
  • Cancelreply