private function createTemporaryFile($resource)
    {
        $path = tempnam(sys_get_temp_dir(), 'media');
        $tempResource = fopen($path, 'w');

        stream_copy_to_stream($resource, $tempResource);

        return $path;
    }