code/extensions/CDNFile.php
public function moveToCdn($newCdn) {
        $reader = $this->reader();

        // gets the _new_ writer
        $writer = $this->getCDNWriter();

        // hooking it to match the current cdn path.
        $writer->setId($reader->getId());
        $writer->write($reader);

        $this->owner->CDNFile = $writer->getContentId();
        $this->owner->write();

        // do the same for all versions
        if ($this->owner->hasExtension('VersionedFileExtension')) {
            foreach ($this->owner->Versions() as $version) {
                if ($version->hasMethod('moveToCdn')) {
                    try {
                        $version->moveToCdn($newCdn);
                    } catch (Exception $ex) {

                    }
                }
            }
        }

        // delete source
        $newReader = $writer->getReader();
        if ($newReader->exists() && $newReader->getContentId() != $reader->getContentId()) {
            $oldWriter = $reader->getWriter();
            $oldWriter->delete();
        }
    }
public function moveToCdn($newCdn) {
        $reader = $this->reader();

        // gets the _new_ writer
        $writer = $this->getCDNWriter();

        // hooking it to match the current cdn path.
        $writer->setId($reader->getId());
        $writer->write($reader);

        $this->owner->CDNFile = $writer->getContentId();
        $this->owner->write();

        // do the same for all versions
        if ($this->owner->hasExtension('VersionedFileExtension')) {
            foreach ($this->owner->Versions() as $version) {
                if ($version->hasMethod('moveToCdn')) {
                    try {
                        $version->moveToCdn($newCdn);
                    } catch (Exception $ex) {

                    }
                }
            }
        }

        // delete source
        $newReader = $writer->getReader();
        if ($newReader->exists() && $newReader->getContentId() != $reader->getContentId()) {
            $oldWriter = $reader->getWriter();
            $oldWriter->delete();
        }
    }
public function moveToCdn ( $ newCdn ) { $ reader = $ this -> reader ( ) ; // gets the _new_ writer $ writer = $ this -> getCDNWriter ( ) ; // hooking it to match the current cdn path. $ writer -> setId ( $ reader -> getId ( ) ) ; $ writer -> write ( $ reader ) ; $ this -> owner -> CDNFile = $ writer -> getContentId ( ) ; $ this -> owner -> write ( ) ; // do the same for all versions if ( $ this -> owner -> hasExtension ( 'VersionedFileExtension' ) ) { foreach ( $ this -> owner -> Versions ( ) as $ version ) { if ( $ version -> hasMethod ( 'moveToCdn' ) ) { try { $ version -> moveToCdn ( $ newCdn ) ; } catch ( Exception $ ex ) { } } } } // delete source $ newReader = $ writer -> getReader ( ) ; if ( $ newReader -> exists ( ) && $ newReader -> getContentId ( ) != $ reader -> getContentId ( ) ) { $ oldWriter = $ reader -> getWriter ( ) ; $ oldWriter -> delete ( ) ; } }
Moves this file to its same path on the named CDN

@param string $newCdn
Moves this file to its same path on the named CDN