hasHeader('x-amz-content-sha256')) { $request->setHeader('x-amz-content-sha256', $this->getPresignedPayload($request)); } parent::signRequest($request, $credentials); } /** * Override used to allow pre-signed URLs to be created for an * in-determinate request payload. */ protected function getPresignedPayload(RequestInterface $request) { $result = parent::getPresignedPayload($request); // If the body is empty, then sign with 'UNSIGNED-PAYLOAD' if ($result === self::DEFAULT_PAYLOAD) { $result = hash('sha256', 'UNSIGNED-PAYLOAD'); } return $result; } /** * Amazon S3 does not double-encode the path component in the canonical req */ protected function createCanonicalizedPath(RequestInterface $request) { return '/' . ltrim($request->getPath(), '/'); } }