PHP SDK文档:
https://help.aliyun.com/document_detail/32104.html?spm=5176.product8314910_31815.6.378.Yn03UD
PHP下载的代码
function getObjectToLocalFile($ossClient, $bucket)
{
$object = "a.zip";
$localfile = "a.zip;
$options = array(
OssClient::OSS_FILE_DOWNLOAD => $localfile,
);
try{
$ossClient->getObject($bucket, $object, $options);
} catch(OssException $e) {
printf(__FUNCTION__ . ": FAILED\n");
printf($e->getMessage() . "\n");
return;
}
print(__FUNCTION__ . ": OK, please check localfile: 'upload-test-object-name.txt'" . "\n");
}
用户点击另存为需要在Put的时候设置Content-Disposition", "attachment;filename=b.zip":
设置在options中
/**
* 上传内存中的内容
*
* @param string $bucket bucket名称
* @param string $object objcet名称
* @param string $content 上传的内容
* @param array $options
* @return null
*/
public function putObject($bucket, $object, $content, $options = NULL)
{
$this->precheckCommon($bucket, $object, $options);
OssUtil::validateContent($content);
$options[self::OSS_CONTENT] = $content;
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_PUT;
$options[self::OSS_OBJECT] = $object;
if (!isset($options[self::OSS_LENGTH])) {
$options[self::OSS_CONTENT_LENGTH] = strlen($options[self::OSS_CONTENT]);
} else {
$options[self::OSS_CONTENT_LENGTH] = $options[self::OSS_LENGTH];
}
if (!isset($options[self::OSS_CONTENT_TYPE])) {
$options[self::OSS_CONTENT_TYPE] = $this->getMimeType($object);
}
$response = $this->auth($options);
$result = new PutSetDeleteResult($response);
return $result->getData();
}