nextHandler = $nextHandler; } public function __invoke(\DeliciousBrains\WP_Offload_Media\Aws3\Aws\CommandInterface $command, \DeliciousBrains\WP_Offload_Media\Aws3\Psr\Http\Message\RequestInterface $request) { $next = $this->nextHandler; $name = $command->getName(); $body = $request->getBody(); if (in_array($name, self::$md5) && !$request->hasHeader('Content-MD5')) { // Set the content MD5 header for operations that require it. $request = $request->withHeader('Content-MD5', base64_encode(\DeliciousBrains\WP_Offload_Media\Aws3\GuzzleHttp\Psr7\hash($body, 'md5', true))); } elseif (in_array($name, self::$sha256) && $command['ContentSHA256']) { // Set the content hash header if provided in the parameters. $request = $request->withHeader('X-Amz-Content-Sha256', $command['ContentSHA256']); } return $next($command, $request); } }