文件
yjyf/server/addons/cos/library/Qcloud/Cos/Request/BodyLocation.php
YuanWen 78d45eea74 chore: 新增epay和cos插件相关类库及配置文件
- 新增epay v2、v3、v3new版本的支付类库及证书文件
- 新增cos云存储类库文件
- 调整文件上传保存格式为按分类存储
- 修复会员、规则、类目等语言翻译键名
- 新增小程序图标等静态资源文件
2026-11-04 09:33:57 +08:00

50 行
1.3 KiB
PHP

<?php
namespace Qcloud\Cos\Request;
use GuzzleHttp\Command\Guzzle\RequestLocation\AbstractLocation;
use GuzzleHttp\Command\CommandInterface;
use GuzzleHttp\Command\Guzzle\Parameter;
use GuzzleHttp\Psr7;
use Psr\Http\Message\MessageInterface;
use Psr\Http\Message\RequestInterface;
/**
* Adds a raw/binary body to a request.
* This is here because: https://github.com/guzzle/guzzle-services/issues/160
*/
class BodyLocation extends AbstractLocation
{
/**
* Set the name of the location
*
* @param string $locationName
*/
public function __construct($locationName = 'body')
{
parent::__construct($locationName);
}
/**
* @param CommandInterface $command
* @param RequestInterface $request
* @param Parameter $param
*
* @return MessageInterface
*/
public function visit(
CommandInterface $command,
RequestInterface $request,
Parameter $param
) {
$value = $request->getBody()->getContents();
if ('' !== $value) {
throw new \RuntimeException('Only one "body" location may exist per operation');
}
// binary string data from bound parameter
$value = $command[$param->getName()];
return $request->withBody(Psr7\Utils::streamFor($value));
}
}