code/content/ContentDeliveryService.php
public function storeThemeFile($toCdn, $file, $forceUpdate = false, $processReferences = false) {
		$mtime = @filemtime($file);
		$relativeName = self::CDN_THEME_PREFIX . '/' . $mtime . '/' . trim(str_replace(Director::baseFolder(), '', $file), '/');
		
		if (!$forceUpdate) {
			// see if the file already exists, if not we do NOT do an update
			$reader = $this->contentService->findReaderFor($toCdn, $relativeName);
			if ($reader && $reader->exists()) {
				return $reader->getURL();
			}
		}

		$clear = false;
		if ($processReferences) {
			$clear = true;
			$file = $this->processFileReferences($toCdn, $file, $forceUpdate);
		}

		// otherwise, lets get a content writer
		$writer = $this->contentService->getWriter($toCdn);
		try {
			$writer->write($file, $relativeName);
		} catch (Exception $e) {
			SS_Log::log($e, SS_Log::WARN);
		}

		if ($clear && strpos($file, '.cdn') > 0) {
			@unlink($file);
		}

		$id = $writer->getContentId();
		return $writer->getReader()->getURL();
	}
public function storeThemeFile($toCdn, $file, $forceUpdate = false, $processReferences = false) {
		$mtime = @filemtime($file);
		$relativeName = self::CDN_THEME_PREFIX . '/' . $mtime . '/' . trim(str_replace(Director::baseFolder(), '', $file), '/');
		
		if (!$forceUpdate) {
			// see if the file already exists, if not we do NOT do an update
			$reader = $this->contentService->findReaderFor($toCdn, $relativeName);
			if ($reader && $reader->exists()) {
				return $reader->getURL();
			}
		}

		$clear = false;
		if ($processReferences) {
			$clear = true;
			$file = $this->processFileReferences($toCdn, $file, $forceUpdate);
		}

		// otherwise, lets get a content writer
		$writer = $this->contentService->getWriter($toCdn);
		try {
			$writer->write($file, $relativeName);
		} catch (Exception $e) {
			SS_Log::log($e, SS_Log::WARN);
		}

		if ($clear && strpos($file, '.cdn') > 0) {
			@unlink($file);
		}

		$id = $writer->getContentId();
		return $writer->getReader()->getURL();
	}
public function storeThemeFile ( $ toCdn , $ file , $ forceUpdate = false , $ processReferences = false ) { $ mtime = @ filemtime ( $ file ) ; $ relativeName = self :: CDN_THEME_PREFIX . '/' . $ mtime . '/' . trim ( str_replace ( Director :: baseFolder ( ) , '' , $ file ) , '/' ) ; if ( ! $ forceUpdate ) { // see if the file already exists, if not we do NOT do an update $ reader = $ this -> contentService -> findReaderFor ( $ toCdn , $ relativeName ) ; if ( $ reader && $ reader -> exists ( ) ) { return $ reader -> getURL ( ) ; } } $ clear = false ; if ( $ processReferences ) { $ clear = true ; $ file = $ this -> processFileReferences ( $ toCdn , $ file , $ forceUpdate ) ; } // otherwise, lets get a content writer $ writer = $ this -> contentService -> getWriter ( $ toCdn ) ; try { $ writer -> write ( $ file , $ relativeName ) ; } catch ( Exception $ e ) { SS_Log :: log ( $ e , SS_Log :: WARN ) ; } if ( $ clear && strpos ( $ file , '.cdn' ) > 0 ) { @ unlink ( $ file ) ; } $ id = $ writer -> getContentId ( ) ; return $ writer -> getReader ( ) -> getURL ( ) ; }
Store the contents of a folder on a CDN.

If processReferences is set, relative URL references are attempted to be
detected and stored remotely as well, with the file to be stored rewritten
to refer to the CDN value. This really is only useful for CSS

@param string $folder
@param boolean $processReferences
Store the contents of a folder on a CDN .