concrete/src/Entity/File/File.php
public function setFileStorageLocation(\Concrete\Core\Entity\File\StorageLocation\StorageLocation $newLocation)
    {
        $fh = Loader::helper('concrete/file');
        $currentLocation = $this->getFileStorageLocationObject();
        if ($newLocation->getID() == $currentLocation->getID()) {
            return false;
        }

        $currentFilesystem = $currentLocation->getFileSystemObject();

        $newFileSystem = $newLocation->getFileSystemObject();

        $list = $this->getVersionList();
        try {
            foreach ($list as $fv) {
                $manager = new \League\Flysystem\MountManager([
                    'current' => $currentFilesystem,
                    'new' => $newFileSystem,
                ]);
                $fp = $fh->prefix($fv->getPrefix(), $fv->getFilename());
                $manager->move('current://' . $fp, 'new://' . $fp);

                $thumbs = Type::getVersionList();
                foreach ($thumbs as $type) {
                    $fv->updateThumbnailStorageLocation($type, $newLocation);
                }
            }
        } catch (\Exception $e) {
            throw new \Exception($e->getMessage());
        }

        $this->setStorageLocation($newLocation);
        $this->save();
    }
public function setFileStorageLocation(\Concrete\Core\Entity\File\StorageLocation\StorageLocation $newLocation)
    {
        $fh = Loader::helper('concrete/file');
        $currentLocation = $this->getFileStorageLocationObject();
        if ($newLocation->getID() == $currentLocation->getID()) {
            return false;
        }

        $currentFilesystem = $currentLocation->getFileSystemObject();

        $newFileSystem = $newLocation->getFileSystemObject();

        $list = $this->getVersionList();
        try {
            foreach ($list as $fv) {
                $manager = new \League\Flysystem\MountManager([
                    'current' => $currentFilesystem,
                    'new' => $newFileSystem,
                ]);
                $fp = $fh->prefix($fv->getPrefix(), $fv->getFilename());
                $manager->move('current://' . $fp, 'new://' . $fp);

                $thumbs = Type::getVersionList();
                foreach ($thumbs as $type) {
                    $fv->updateThumbnailStorageLocation($type, $newLocation);
                }
            }
        } catch (\Exception $e) {
            throw new \Exception($e->getMessage());
        }

        $this->setStorageLocation($newLocation);
        $this->save();
    }
public function setFileStorageLocation ( \ Concrete \ Core \ Entity \ File \ StorageLocation \ StorageLocation $ newLocation ) { $ fh = Loader :: helper ( 'concrete/file' ) ; $ currentLocation = $ this -> getFileStorageLocationObject ( ) ; if ( $ newLocation -> getID ( ) == $ currentLocation -> getID ( ) ) { return false ; } $ currentFilesystem = $ currentLocation -> getFileSystemObject ( ) ; $ newFileSystem = $ newLocation -> getFileSystemObject ( ) ; $ list = $ this -> getVersionList ( ) ; try { foreach ( $ list as $ fv ) { $ manager = new \ League \ Flysystem \ MountManager ( [ 'current' => $ currentFilesystem , 'new' => $ newFileSystem , ] ) ; $ fp = $ fh -> prefix ( $ fv -> getPrefix ( ) , $ fv -> getFilename ( ) ) ; $ manager -> move ( 'current://' . $ fp , 'new://' . $ fp ) ; $ thumbs = Type :: getVersionList ( ) ; foreach ( $ thumbs as $ type ) { $ fv -> updateThumbnailStorageLocation ( $ type , $ newLocation ) ; } } } catch ( \ Exception $ e ) { throw new \ Exception ( $ e -> getMessage ( ) ) ; } $ this -> setStorageLocation ( $ newLocation ) ; $ this -> save ( ) ; }
Move a file from its current FSL to a new FSL.

@param StorageLocation\StorageLocation $newLocation

@return bool false if the storage location is the same

@throws \Exception
Move a file from its current FSL to a new FSL .