Classes/StorageFactory.php
public function create($credentialsProfileName = 'default')
    {
        if (!isset($this->credentialProfiles[$credentialsProfileName])) {
            throw new Exception(sprintf('The specified Google Cloud Storage credentials profile "%s" does not exist, please check your settings.', $credentialsProfileName), 1446553024);
        }

        if (!empty($this->credentialProfiles[$credentialsProfileName]['credentials']['privateKeyJsonBase64Encoded'])) {
            $googleCloud = new ServiceBuilder([
                'keyFile' => json_decode(base64_decode($this->credentialProfiles[$credentialsProfileName]['credentials']['privateKeyJsonBase64Encoded']), true)
            ]);
        } else {
            if (substr($this->credentialProfiles[$credentialsProfileName]['credentials']['privateKeyJsonPathAndFilename'], 0, 1) !== '/') {
                $privateKeyPathAndFilename = FLOW_PATH_ROOT . $this->credentialProfiles[$credentialsProfileName]['credentials']['privateKeyJsonPathAndFilename'];
            } else {
                $privateKeyPathAndFilename = $this->credentialProfiles[$credentialsProfileName]['credentials']['privateKeyJsonPathAndFilename'];
            }

            if (!file_exists($privateKeyPathAndFilename)) {
                throw new Exception(sprintf('The Google Cloud Storage private key file "%s" does not exist. Either the file is missing or you need to adjust your settings.', $privateKeyPathAndFilename), 1446553054);
            }
            $googleCloud = new ServiceBuilder([
                'keyFilePath' => $privateKeyPathAndFilename
            ]);
        }

        return $googleCloud->storage();
    }
public function create($credentialsProfileName = 'default')
    {
        if (!isset($this->credentialProfiles[$credentialsProfileName])) {
            throw new Exception(sprintf('The specified Google Cloud Storage credentials profile "%s" does not exist, please check your settings.', $credentialsProfileName), 1446553024);
        }

        if (!empty($this->credentialProfiles[$credentialsProfileName]['credentials']['privateKeyJsonBase64Encoded'])) {
            $googleCloud = new ServiceBuilder([
                'keyFile' => json_decode(base64_decode($this->credentialProfiles[$credentialsProfileName]['credentials']['privateKeyJsonBase64Encoded']), true)
            ]);
        } else {
            if (substr($this->credentialProfiles[$credentialsProfileName]['credentials']['privateKeyJsonPathAndFilename'], 0, 1) !== '/') {
                $privateKeyPathAndFilename = FLOW_PATH_ROOT . $this->credentialProfiles[$credentialsProfileName]['credentials']['privateKeyJsonPathAndFilename'];
            } else {
                $privateKeyPathAndFilename = $this->credentialProfiles[$credentialsProfileName]['credentials']['privateKeyJsonPathAndFilename'];
            }

            if (!file_exists($privateKeyPathAndFilename)) {
                throw new Exception(sprintf('The Google Cloud Storage private key file "%s" does not exist. Either the file is missing or you need to adjust your settings.', $privateKeyPathAndFilename), 1446553054);
            }
            $googleCloud = new ServiceBuilder([
                'keyFilePath' => $privateKeyPathAndFilename
            ]);
        }

        return $googleCloud->storage();
    }
public function create ( $ credentialsProfileName = 'default' ) { if ( ! isset ( $ this -> credentialProfiles [ $ credentialsProfileName ] ) ) { throw new Exception ( sprintf ( 'The specified Google Cloud Storage credentials profile "%s" does not exist, please check your settings.' , $ credentialsProfileName ) , 1446553024 ) ; } if ( ! empty ( $ this -> credentialProfiles [ $ credentialsProfileName ] [ 'credentials' ] [ 'privateKeyJsonBase64Encoded' ] ) ) { $ googleCloud = new ServiceBuilder ( [ 'keyFile' => json_decode ( base64_decode ( $ this -> credentialProfiles [ $ credentialsProfileName ] [ 'credentials' ] [ 'privateKeyJsonBase64Encoded' ] ) , true ) ] ) ; } else { if ( substr ( $ this -> credentialProfiles [ $ credentialsProfileName ] [ 'credentials' ] [ 'privateKeyJsonPathAndFilename' ] , 0 , 1 ) !== '/' ) { $ privateKeyPathAndFilename = FLOW_PATH_ROOT . $ this -> credentialProfiles [ $ credentialsProfileName ] [ 'credentials' ] [ 'privateKeyJsonPathAndFilename' ] ; } else { $ privateKeyPathAndFilename = $ this -> credentialProfiles [ $ credentialsProfileName ] [ 'credentials' ] [ 'privateKeyJsonPathAndFilename' ] ; } if ( ! file_exists ( $ privateKeyPathAndFilename ) ) { throw new Exception ( sprintf ( 'The Google Cloud Storage private key file "%s" does not exist. Either the file is missing or you need to adjust your settings.' , $ privateKeyPathAndFilename ) , 1446553054 ) ; } $ googleCloud = new ServiceBuilder ( [ 'keyFilePath' => $ privateKeyPathAndFilename ] ) ; } return $ googleCloud -> storage ( ) ; }
Creates a new Storage instance and authenticates against the Google API

@param string $credentialsProfileName
@return \Google\Cloud\Storage\StorageClient
@throws Exception
Creates a new Storage instance and authenticates against the Google API