private function fileMove($overwrite = true)
    {
        if (!$this->file->getLocation() || $overwrite) {
            $origin = $this->file->getTmp();

            // This will typically be /media/files
            $uploadDir = realpath($this->coreParametersHelper->getParameter('upload_dir'));
            $fileName  = $this->getFileName(
                $this->file->getCompression()
            );
            $target    = $uploadDir.'/client_payloads/'.$this->contactClient->getId().'/'.$fileName;
            if ($origin && (!file_exists($target) || $overwrite)) {
                $this->filesystemLocal->copy($origin, $target, $overwrite);
                if (file_exists($target)) {
                    // Final file name as it will be seen by the client.
                    $this->file->setName($fileName);
                    $this->setLogs($fileName, 'fileName');

                    $this->file->setDateAdded(new \DateTime());

                    $this->file->setLocation($target);
                    $this->setLogs($target, 'fileLocation');

                    $crc32 = hash_file('crc32b', $target);
                    $this->file->setCrc32($crc32);
                    $this->setLogs($crc32, 'crc32');

                    $md5 = hash_file('md5', $target);
                    $this->file->setMd5($md5);
                    $this->setLogs($md5, 'md5');

                    $sha1 = hash_file('sha1', $target);
                    $this->file->setSha1($sha1);
                    $this->setLogs($sha1, 'sha1');

                    $this->setLogs(filesize($target), 'fileSize');

                    $this->filesystemLocal->remove($origin);

                    $this->file->setStatus(File::STATUS_READY);
                    $this->setLogs($this->file->getStatus(), 'fileStatus');
                } else {
                    throw new ContactClientException(
                        'Could not move file to local location.',
                        Codes::HTTP_INTERNAL_SERVER_ERROR,
                        null,
                        Stat::TYPE_ERROR,
                        false
                    );
                }
            }
        }

        return $this;
    }
private function fileMove($overwrite = true)
    {
        if (!$this->file->getLocation() || $overwrite) {
            $origin = $this->file->getTmp();

            // This will typically be /media/files
            $uploadDir = realpath($this->coreParametersHelper->getParameter('upload_dir'));
            $fileName  = $this->getFileName(
                $this->file->getCompression()
            );
            $target    = $uploadDir.'/client_payloads/'.$this->contactClient->getId().'/'.$fileName;
            if ($origin && (!file_exists($target) || $overwrite)) {
                $this->filesystemLocal->copy($origin, $target, $overwrite);
                if (file_exists($target)) {
                    // Final file name as it will be seen by the client.
                    $this->file->setName($fileName);
                    $this->setLogs($fileName, 'fileName');

                    $this->file->setDateAdded(new \DateTime());

                    $this->file->setLocation($target);
                    $this->setLogs($target, 'fileLocation');

                    $crc32 = hash_file('crc32b', $target);
                    $this->file->setCrc32($crc32);
                    $this->setLogs($crc32, 'crc32');

                    $md5 = hash_file('md5', $target);
                    $this->file->setMd5($md5);
                    $this->setLogs($md5, 'md5');

                    $sha1 = hash_file('sha1', $target);
                    $this->file->setSha1($sha1);
                    $this->setLogs($sha1, 'sha1');

                    $this->setLogs(filesize($target), 'fileSize');

                    $this->filesystemLocal->remove($origin);

                    $this->file->setStatus(File::STATUS_READY);
                    $this->setLogs($this->file->getStatus(), 'fileStatus');
                } else {
                    throw new ContactClientException(
                        'Could not move file to local location.',
                        Codes::HTTP_INTERNAL_SERVER_ERROR,
                        null,
                        Stat::TYPE_ERROR,
                        false
                    );
                }
            }
        }

        return $this;
    }
private function fileMove ( $ overwrite = true ) { if ( ! $ this -> file -> getLocation ( ) || $ overwrite ) { $ origin = $ this -> file -> getTmp ( ) ; // This will typically be /media/files $ uploadDir = realpath ( $ this -> coreParametersHelper -> getParameter ( 'upload_dir' ) ) ; $ fileName = $ this -> getFileName ( $ this -> file -> getCompression ( ) ) ; $ target = $ uploadDir . '/client_payloads/' . $ this -> contactClient -> getId ( ) . '/' . $ fileName ; if ( $ origin && ( ! file_exists ( $ target ) || $ overwrite ) ) { $ this -> filesystemLocal -> copy ( $ origin , $ target , $ overwrite ) ; if ( file_exists ( $ target ) ) { // Final file name as it will be seen by the client. $ this -> file -> setName ( $ fileName ) ; $ this -> setLogs ( $ fileName , 'fileName' ) ; $ this -> file -> setDateAdded ( new \ DateTime ( ) ) ; $ this -> file -> setLocation ( $ target ) ; $ this -> setLogs ( $ target , 'fileLocation' ) ; $ crc32 = hash_file ( 'crc32b' , $ target ) ; $ this -> file -> setCrc32 ( $ crc32 ) ; $ this -> setLogs ( $ crc32 , 'crc32' ) ; $ md5 = hash_file ( 'md5' , $ target ) ; $ this -> file -> setMd5 ( $ md5 ) ; $ this -> setLogs ( $ md5 , 'md5' ) ; $ sha1 = hash_file ( 'sha1' , $ target ) ; $ this -> file -> setSha1 ( $ sha1 ) ; $ this -> setLogs ( $ sha1 , 'sha1' ) ; $ this -> setLogs ( filesize ( $ target ) , 'fileSize' ) ; $ this -> filesystemLocal -> remove ( $ origin ) ; $ this -> file -> setStatus ( File :: STATUS_READY ) ; $ this -> setLogs ( $ this -> file -> getStatus ( ) , 'fileStatus' ) ; } else { throw new ContactClientException ( 'Could not move file to local location.' , Codes :: HTTP_INTERNAL_SERVER_ERROR , null , Stat :: TYPE_ERROR , false ) ; } } } return $ this ; }
Moves the file out of temp, and locks the hashes.

@param bool $overwrite

@return $this

@throws ContactClientException
Moves the file out of temp and locks the hashes .