public function saveContent($filenameResourceOrStream)
    {
        $resourceOrStream = $filenameResourceOrStream;
        if (is_string($filenameResourceOrStream)) {
            $resourceOrStream = fopen($filenameResourceOrStream, 'w+');
        }

        $stream = Psr7\stream_for($resourceOrStream);
        Psr7\copy_to_stream($this->getBinaryContentStream(), $stream);

        if (!is_string($filenameResourceOrStream)
            && !($filenameResourceOrStream instanceof StreamInterface)) {
            // only detach if it wasn't a string or StreamInterface, so the
            // fopen call can be properly closed if it was
            $stream->detach();
        }
    }
public function saveContent($filenameResourceOrStream)
    {
        $resourceOrStream = $filenameResourceOrStream;
        if (is_string($filenameResourceOrStream)) {
            $resourceOrStream = fopen($filenameResourceOrStream, 'w+');
        }

        $stream = Psr7\stream_for($resourceOrStream);
        Psr7\copy_to_stream($this->getBinaryContentStream(), $stream);

        if (!is_string($filenameResourceOrStream)
            && !($filenameResourceOrStream instanceof StreamInterface)) {
            // only detach if it wasn't a string or StreamInterface, so the
            // fopen call can be properly closed if it was
            $stream->detach();
        }
    }
public function saveContent ( $ filenameResourceOrStream ) { $ resourceOrStream = $ filenameResourceOrStream ; if ( is_string ( $ filenameResourceOrStream ) ) { $ resourceOrStream = fopen ( $ filenameResourceOrStream , 'w+' ) ; } $ stream = Psr7 \ stream_for ( $ resourceOrStream ) ; Psr7 \ copy_to_stream ( $ this -> getBinaryContentStream ( ) , $ stream ) ; if ( ! is_string ( $ filenameResourceOrStream ) && ! ( $ filenameResourceOrStream instanceof StreamInterface ) ) { // only detach if it wasn't a string or StreamInterface, so the // fopen call can be properly closed if it was $ stream -> detach ( ) ; } }
Saves the binary content of the stream to the passed file, resource or
stream.

Note that charset conversion is not performed in this case, and the
contents of the part are saved in their binary format as transmitted (but
after any content-transfer decoding is performed).  {@see
MessagePart::getBinaryContentStream()} for a more detailed description of
the stream.

If the passed parameter is a string, it's assumed to be a filename to
write to.  The file is opened in 'w+' mode, and closed before returning.

When passing a resource or Psr7 Stream, the resource is not closed, nor
rewound.

@param string|resource|Stream $filenameResourceOrStream
Saves the binary content of the stream to the passed file resource or stream .