public static function toRavelryPostFile($value, Parameter $parameter)
    {
        if (is_string($value)) {
            $value = fopen($value, 'r');
        }

        if (!($value instanceof StreamInterface)) {
            $value = \GuzzleHttp\Stream\create($value);
        }

        if ($value instanceof MetadataStreamInterface) {
            $filename = $value->getMetadata('uri');
        }

        if (!$filename || substr($filename, 0, 6) === 'php://') {
            $filename = $parameter->getWireName();
        }

        return new PostFile(
            $parameter->getWireName(),
            $value,
            $filename,
            [
                'Content-Disposition' => sprintf(
                    'form-data; name="%s"; filename="%s"',
                    $parameter->getWireName(),
                    basename($filename)
                ),
            ]
        );
    }