original_string: protected function uploadStatic() {
  		// copy to all destination folders
  		foreach($this->remoteStatic as $type => $destDir) {			
  			// copy from all static
  			if(isset($this->s3)) {
  				foreach(self::rglob($this->tmp[ $type ] . '*') as $file) {
  					$info = new \SplFileInfo($file);
  					
  					if($info->isDir() || !$info->isReadable())
  						continue;
  					
  					$this->start('Putting '. $info->getBasename() .' on '. $destDir);
  					
  					// get mime
  					$mime = 'text/plain'; // 'application/octet-stream';
  					if(isset(static::$mimes[ $info->getExtension() ]))
  						$mime = static::$mimes[ $info->getExtension() ];
  					
  					// headers
  					$headers = [
  						'Content-Type'		=> $mime,
  						'Cache-Control'		=> 'max-age=315360000',
  						'Expires'			=> 'Thu, 31 Dec 2037 23:55:55 GMT', //gmdate(DateTime::RFC1123, strtotime('+5 years'))
  						'Vary'				=> 'Accept-Encoding',
  					];
  					
  					$data = file_get_contents($file);
  						
  					// gzip
  					if(substr($mime, 0, 5) === 'text/'
  					|| $mime === 'application/javascript'
  					|| $mime === 'application/x-javascript'
  					|| $mime === 'application/json') {
  						$data = gzencode($data, 9);
  						$headers['Content-Encoding'] = 'gzip';
  					}
  					
  					// data length
  					$headers['Content-Length'] = mb_strlen($data, '8bit');
  					
  					// push it
  					$this->s3->putObject(
  						$data,
  						$destDir,
  						$info->getBasename(),
  						\S3::ACL_PUBLIC_READ,
  						array(),
  						$headers
  					);
  
  					$this->finish();
  				}
  			} else {
  				$this	->start('Local object '. $type .' -> '. $destDir)
  //						->runRemote('rm -r '. $destDir .'; mkdir -p '. $destDir)
  						->runLocal(['pscp',
  							'-p',									// preserve attributes
  							'-r',									// copy recursively
  							'-q',									// silent
  							//'-sftp',								// for use of SFTP protocal
  							'-batch',								// non interactive
  							'-C',									// enable compression
  							'-i', static::safeDir($this->ppk),		// Private key file to access server
  							static::safeDir($this->tmp[ $type ]),	// Directory to upload
  							$this->host .':'. $destDir,	// host:path on server to save data
  						])->finish();
  			}
  		}
  		
  		return $this;
  	}
code: protected function uploadStatic() {
  		// copy to all destination folders
  		foreach($this->remoteStatic as $type => $destDir) {			
  			// copy from all static
  			if(isset($this->s3)) {
  				foreach(self::rglob($this->tmp[ $type ] . '*') as $file) {
  					$info = new \SplFileInfo($file);
  					
  					if($info->isDir() || !$info->isReadable())
  						continue;
  					
  					$this->start('Putting '. $info->getBasename() .' on '. $destDir);
  					
  					// get mime
  					$mime = 'text/plain'; // 'application/octet-stream';
  					if(isset(static::$mimes[ $info->getExtension() ]))
  						$mime = static::$mimes[ $info->getExtension() ];
  					
  					// headers
  					$headers = [
  						'Content-Type'		=> $mime,
  						'Cache-Control'		=> 'max-age=315360000',
  						'Expires'			=> 'Thu, 31 Dec 2037 23:55:55 GMT', //gmdate(DateTime::RFC1123, strtotime('+5 years'))
  						'Vary'				=> 'Accept-Encoding',
  					];
  					
  					$data = file_get_contents($file);
  						
  					// gzip
  					if(substr($mime, 0, 5) === 'text/'
  					|| $mime === 'application/javascript'
  					|| $mime === 'application/x-javascript'
  					|| $mime === 'application/json') {
  						$data = gzencode($data, 9);
  						$headers['Content-Encoding'] = 'gzip';
  					}
  					
  					// data length
  					$headers['Content-Length'] = mb_strlen($data, '8bit');
  					
  					// push it
  					$this->s3->putObject(
  						$data,
  						$destDir,
  						$info->getBasename(),
  						\S3::ACL_PUBLIC_READ,
  						array(),
  						$headers
  					);
  
  					$this->finish();
  				}
  			} else {
  				$this	->start('Local object '. $type .' -> '. $destDir)
  //						->runRemote('rm -r '. $destDir .'; mkdir -p '. $destDir)
  						->runLocal(['pscp',
  							'-p',									// preserve attributes
  							'-r',									// copy recursively
  							'-q',									// silent
  							//'-sftp',								// for use of SFTP protocal
  							'-batch',								// non interactive
  							'-C',									// enable compression
  							'-i', static::safeDir($this->ppk),		// Private key file to access server
  							static::safeDir($this->tmp[ $type ]),	// Directory to upload
  							$this->host .':'. $destDir,	// host:path on server to save data
  						])->finish();
  			}
  		}
  		
  		return $this;
  	}
code_tokens: protected function uploadStatic ( ) { // copy to all destination folders foreach ( $ this -> remoteStatic as $ type => $ destDir ) { // copy from all static if ( isset ( $ this -> s3 ) ) { foreach ( self :: rglob ( $ this -> tmp [ $ type ] . '*' ) as $ file ) { $ info = new \ SplFileInfo ( $ file ) ; if ( $ info -> isDir ( ) || ! $ info -> isReadable ( ) ) continue ; $ this -> start ( 'Putting ' . $ info -> getBasename ( ) . ' on ' . $ destDir ) ; // get mime $ mime = 'text/plain' ; // 'application/octet-stream'; if ( isset ( static :: $ mimes [ $ info -> getExtension ( ) ] ) ) $ mime = static :: $ mimes [ $ info -> getExtension ( ) ] ; // headers $ headers = [ 'Content-Type' => $ mime , 'Cache-Control' => 'max-age=315360000' , 'Expires' => 'Thu, 31 Dec 2037 23:55:55 GMT' , //gmdate(DateTime::RFC1123, strtotime('+5 years')) 'Vary' => 'Accept-Encoding' , ] ; $ data = file_get_contents ( $ file ) ; // gzip if ( substr ( $ mime , 0 , 5 ) === 'text/' || $ mime === 'application/javascript' || $ mime === 'application/x-javascript' || $ mime === 'application/json' ) { $ data = gzencode ( $ data , 9 ) ; $ headers [ 'Content-Encoding' ] = 'gzip' ; } // data length $ headers [ 'Content-Length' ] = mb_strlen ( $ data , '8bit' ) ; // push it $ this -> s3 -> putObject ( $ data , $ destDir , $ info -> getBasename ( ) , \ S3 :: ACL_PUBLIC_READ , array ( ) , $ headers ) ; $ this -> finish ( ) ; } } else { $ this -> start ( 'Local object ' . $ type . ' -> ' . $ destDir ) //						->runRemote('rm -r '. $destDir .'; mkdir -p '. $destDir) -> runLocal ( [ 'pscp' , '-p' , // preserve attributes '-r' , // copy recursively '-q' , // silent //'-sftp',								// for use of SFTP protocal '-batch' , // non interactive '-C' , // enable compression '-i' , static :: safeDir ( $ this -> ppk ) , // Private key file to access server static :: safeDir ( $ this -> tmp [ $ type ] ) , // Directory to upload $ this -> host . ':' . $ destDir , // host:path on server to save data ] ) -> finish ( ) ; } } return $ this ; }
docstring: Uploads to S3 or remote server
docstring_tokens: Uploads to S3 or remote server