public function createTemporaryLocalCopy()
    {
        if ($this->temporaryLocalCopyPathAndFilename === null) {
            $temporaryPathAndFilename = $this->environment->getPathToTemporaryDirectory() . 'ResourceFiles/';
            try {
                Utility\Files::createDirectoryRecursively($temporaryPathAndFilename);
            } catch (Utility\Exception\FilesException $e) {
                throw new ResourceException(sprintf('Could not create the temporary directory %s while trying to create a temporary local copy of resource %s (%s).', $temporaryPathAndFilename, $this->sha1, $this->filename), 1416221864);
            }

            $temporaryPathAndFilename .= $this->getCacheEntryIdentifier();
            $temporaryPathAndFilename .= '-' . microtime(true);

            if (function_exists('posix_getpid')) {
                $temporaryPathAndFilename .= '-' . str_pad(posix_getpid(), 10);
            } else {
                $temporaryPathAndFilename .= '-' . (string) getmypid();
            }

            $temporaryPathAndFilename = trim($temporaryPathAndFilename);
            $temporaryFileHandle = fopen($temporaryPathAndFilename, 'w');
            if ($temporaryFileHandle === false) {
                throw new ResourceException(sprintf('Could not create the temporary file %s while trying to create a temporary local copy of resource %s (%s).', $temporaryPathAndFilename, $this->sha1, $this->filename), 1416221864);
            }
            $resourceStream = $this->getStream();
            if ($resourceStream === false) {
                throw new ResourceException(sprintf('Could not open stream for resource %s ("%s") from collection "%s" while trying to create a temporary local copy.', $this->sha1, $this->filename, $this->collectionName), 1416221863);
            }
            stream_copy_to_stream($resourceStream, $temporaryFileHandle);
            fclose($resourceStream);
            fclose($temporaryFileHandle);
            $this->temporaryLocalCopyPathAndFilename = $temporaryPathAndFilename;
        }

        return $this->temporaryLocalCopyPathAndFilename;
    }
public function createTemporaryLocalCopy()
    {
        if ($this->temporaryLocalCopyPathAndFilename === null) {
            $temporaryPathAndFilename = $this->environment->getPathToTemporaryDirectory() . 'ResourceFiles/';
            try {
                Utility\Files::createDirectoryRecursively($temporaryPathAndFilename);
            } catch (Utility\Exception\FilesException $e) {
                throw new ResourceException(sprintf('Could not create the temporary directory %s while trying to create a temporary local copy of resource %s (%s).', $temporaryPathAndFilename, $this->sha1, $this->filename), 1416221864);
            }

            $temporaryPathAndFilename .= $this->getCacheEntryIdentifier();
            $temporaryPathAndFilename .= '-' . microtime(true);

            if (function_exists('posix_getpid')) {
                $temporaryPathAndFilename .= '-' . str_pad(posix_getpid(), 10);
            } else {
                $temporaryPathAndFilename .= '-' . (string) getmypid();
            }

            $temporaryPathAndFilename = trim($temporaryPathAndFilename);
            $temporaryFileHandle = fopen($temporaryPathAndFilename, 'w');
            if ($temporaryFileHandle === false) {
                throw new ResourceException(sprintf('Could not create the temporary file %s while trying to create a temporary local copy of resource %s (%s).', $temporaryPathAndFilename, $this->sha1, $this->filename), 1416221864);
            }
            $resourceStream = $this->getStream();
            if ($resourceStream === false) {
                throw new ResourceException(sprintf('Could not open stream for resource %s ("%s") from collection "%s" while trying to create a temporary local copy.', $this->sha1, $this->filename, $this->collectionName), 1416221863);
            }
            stream_copy_to_stream($resourceStream, $temporaryFileHandle);
            fclose($resourceStream);
            fclose($temporaryFileHandle);
            $this->temporaryLocalCopyPathAndFilename = $temporaryPathAndFilename;
        }

        return $this->temporaryLocalCopyPathAndFilename;
    }
public function createTemporaryLocalCopy ( ) { if ( $ this -> temporaryLocalCopyPathAndFilename === null ) { $ temporaryPathAndFilename = $ this -> environment -> getPathToTemporaryDirectory ( ) . 'ResourceFiles/' ; try { Utility \ Files :: createDirectoryRecursively ( $ temporaryPathAndFilename ) ; } catch ( Utility \ Exception \ FilesException $ e ) { throw new ResourceException ( sprintf ( 'Could not create the temporary directory %s while trying to create a temporary local copy of resource %s (%s).' , $ temporaryPathAndFilename , $ this -> sha1 , $ this -> filename ) , 1416221864 ) ; } $ temporaryPathAndFilename .= $ this -> getCacheEntryIdentifier ( ) ; $ temporaryPathAndFilename .= '-' . microtime ( true ) ; if ( function_exists ( 'posix_getpid' ) ) { $ temporaryPathAndFilename .= '-' . str_pad ( posix_getpid ( ) , 10 ) ; } else { $ temporaryPathAndFilename .= '-' . ( string ) getmypid ( ) ; } $ temporaryPathAndFilename = trim ( $ temporaryPathAndFilename ) ; $ temporaryFileHandle = fopen ( $ temporaryPathAndFilename , 'w' ) ; if ( $ temporaryFileHandle === false ) { throw new ResourceException ( sprintf ( 'Could not create the temporary file %s while trying to create a temporary local copy of resource %s (%s).' , $ temporaryPathAndFilename , $ this -> sha1 , $ this -> filename ) , 1416221864 ) ; } $ resourceStream = $ this -> getStream ( ) ; if ( $ resourceStream === false ) { throw new ResourceException ( sprintf ( 'Could not open stream for resource %s ("%s") from collection "%s" while trying to create a temporary local copy.' , $ this -> sha1 , $ this -> filename , $ this -> collectionName ) , 1416221863 ) ; } stream_copy_to_stream ( $ resourceStream , $ temporaryFileHandle ) ; fclose ( $ resourceStream ) ; fclose ( $ temporaryFileHandle ) ; $ this -> temporaryLocalCopyPathAndFilename = $ temporaryPathAndFilename ; } return $ this -> temporaryLocalCopyPathAndFilename ; }
Returns the path to a local file representing this resource for use with read-only file operations such as reading or copying.

Note that you must not store or publish file paths returned from this method as they will change with every request.

@return string Absolute path and filename pointing to the temporary local copy of this resource
@throws Exception
@api
Returns the path to a local file representing this resource for use with read - only file operations such as reading or copying .