static public function attachData(Request $request, $body): Request {
        $headers = $request->getHeaders();
        if (is_string($body) && file_exists($body)) {
            $filename                       = rawurldecode(basename($body)); // lucky guess - unfortunately it is not clear how to escape header values
            $headers['Content-Disposition'] = 'attachment; filename="' . $filename . '"';

            $mime = @mime_content_type($body);
            if ($mime) {
                $headers['Content-Type'] = $mime;
            }
            $body = fopen($body, 'rb');
        } elseif (is_array($body) && isset($body['contentType']) && isset($body['data']) && isset($body['filename'])) {
            $headers['Content-Type']        = $body['contentType'];
            $headers['Content-Disposition'] = 'attachment; filename="' . rawurldecode($body['filename']) . '"';
            $body                           = file_exists($body['data']) ? fopen($body['data'], 'rb') : $body['data'];
        } elseif (is_string($body) && preg_match('|^[a-z0-9]+://|i', $body)) {
            $headers['Content-Type'] = 'message/external-body; access-type=URL; URL="' . $body . '"';
            $body                    = null;
        }
        return new Request($request->getMethod(), $request->getUri(), $headers, $body);
    }