public function createChunkFileName($additionalName = null, $currentChunkIndex = null)
    {
        // prepare basic name structure
        $array = [
            $this->file->getClientOriginalName(),
        ];

        // ensure that the chunk name is for unique for the client session
        $useSession = $this->config->chunkUseSessionForName();
        $useBrowser = $this->config->chunkUseBrowserInfoForName();
        if ($useSession && false === static::canUseSession()) {
            $useBrowser = true;
            $useSession = false;
        }

        // the session needs more config on the provider
        if ($useSession) {
            $array[] = Session::getId();
        }

        // can work without any additional setup
        if ($useBrowser) {
            $array[] = md5($this->request->ip().$this->request->header('User-Agent', 'no-browser'));
        }

        // Add additional name for more unique chunk name
        if (!is_null($additionalName)) {
            $array[] = $additionalName;
        }

        // Build the final name - parts separated by dot
        $namesSeparatedByDot = [
            implode('-', $array),
        ];

        // Add the chunk index for parallel upload
        if (null !== $currentChunkIndex) {
            $namesSeparatedByDot[] = $currentChunkIndex;
        }

        // Add extension
        $namesSeparatedByDot[] = ChunkStorage::CHUNK_EXTENSION;

        // build name
        return implode('.', $namesSeparatedByDot);
    }
public function createChunkFileName($additionalName = null, $currentChunkIndex = null)
    {
        // prepare basic name structure
        $array = [
            $this->file->getClientOriginalName(),
        ];

        // ensure that the chunk name is for unique for the client session
        $useSession = $this->config->chunkUseSessionForName();
        $useBrowser = $this->config->chunkUseBrowserInfoForName();
        if ($useSession && false === static::canUseSession()) {
            $useBrowser = true;
            $useSession = false;
        }

        // the session needs more config on the provider
        if ($useSession) {
            $array[] = Session::getId();
        }

        // can work without any additional setup
        if ($useBrowser) {
            $array[] = md5($this->request->ip().$this->request->header('User-Agent', 'no-browser'));
        }

        // Add additional name for more unique chunk name
        if (!is_null($additionalName)) {
            $array[] = $additionalName;
        }

        // Build the final name - parts separated by dot
        $namesSeparatedByDot = [
            implode('-', $array),
        ];

        // Add the chunk index for parallel upload
        if (null !== $currentChunkIndex) {
            $namesSeparatedByDot[] = $currentChunkIndex;
        }

        // Add extension
        $namesSeparatedByDot[] = ChunkStorage::CHUNK_EXTENSION;

        // build name
        return implode('.', $namesSeparatedByDot);
    }
public function createChunkFileName ( $ additionalName = null , $ currentChunkIndex = null ) { // prepare basic name structure $ array = [ $ this -> file -> getClientOriginalName ( ) , ] ; // ensure that the chunk name is for unique for the client session $ useSession = $ this -> config -> chunkUseSessionForName ( ) ; $ useBrowser = $ this -> config -> chunkUseBrowserInfoForName ( ) ; if ( $ useSession && false === static :: canUseSession ( ) ) { $ useBrowser = true ; $ useSession = false ; } // the session needs more config on the provider if ( $ useSession ) { $ array [ ] = Session :: getId ( ) ; } // can work without any additional setup if ( $ useBrowser ) { $ array [ ] = md5 ( $ this -> request -> ip ( ) . $ this -> request -> header ( 'User-Agent' , 'no-browser' ) ) ; } // Add additional name for more unique chunk name if ( ! is_null ( $ additionalName ) ) { $ array [ ] = $ additionalName ; } // Build the final name - parts separated by dot $ namesSeparatedByDot = [ implode ( '-' , $ array ) , ] ; // Add the chunk index for parallel upload if ( null !== $ currentChunkIndex ) { $ namesSeparatedByDot [ ] = $ currentChunkIndex ; } // Add extension $ namesSeparatedByDot [ ] = ChunkStorage :: CHUNK_EXTENSION ; // build name return implode ( '.' , $ namesSeparatedByDot ) ; }
Builds the chunk file name per session and the original name. You can
provide custom additional name at the end of the generated file name. All chunk
files has .part extension.

@param string|null $additionalName    Make the name more unique (example: use id from request)
@param string|null $currentChunkIndex Add the chunk index for parallel upload

@return string

@see UploadedFile::getClientOriginalName()
@see Session::getId()
Builds the chunk file name per session and the original name . You can provide custom additional name at the end of the generated file name . All chunk files has . part extension .