public static function getPublicUrl($gs_filename, $use_https) {
    if (!is_bool($use_https)) {
      throw new \InvalidArgumentException(
          'Parameter $use_https must be boolean but was ' .
          typeOrClass($use_https));
    }

    if (!self::parseFilename($gs_filename, $bucket, $object)) {
      throw new \InvalidArgumentException(
          sprintf('Invalid Google Cloud Storage filename: %s',
                  htmlspecialchars($gs_filename)));
    }

    if (self::isDevelServer()) {
      $scheme = 'http';
      $host = getenv('HTTP_HOST');
      $path = sprintf('%s/%s%s', self::LOCAL_ENDPOINT, $bucket, $object);
    } else {
      // Use path format for HTTPS URL when the bucket name contains "." to
      // avoid SSL certificate validation issue.
      if ($use_https && strpos($bucket, '.') !== false) {
        $host = self::PRODUCTION_HOST_PATH_FORMAT;
        $path = sprintf('/%s%s', $bucket, $object);
      } else {
        $host = sprintf(self::PRODUCTION_HOST_SUBDOMAIN_FORMAT, $bucket);
        $path = strlen($object) > 0 ? $object : '/';
      }

      $scheme = $use_https ? 'https' : 'http';
    }

    return sprintf('%s://%s%s',
                   $scheme,
                   $host,
                   strtr($path, self::$url_path_translation_map));
  }
public static function getPublicUrl($gs_filename, $use_https) {
    if (!is_bool($use_https)) {
      throw new \InvalidArgumentException(
          'Parameter $use_https must be boolean but was ' .
          typeOrClass($use_https));
    }

    if (!self::parseFilename($gs_filename, $bucket, $object)) {
      throw new \InvalidArgumentException(
          sprintf('Invalid Google Cloud Storage filename: %s',
                  htmlspecialchars($gs_filename)));
    }

    if (self::isDevelServer()) {
      $scheme = 'http';
      $host = getenv('HTTP_HOST');
      $path = sprintf('%s/%s%s', self::LOCAL_ENDPOINT, $bucket, $object);
    } else {
      // Use path format for HTTPS URL when the bucket name contains "." to
      // avoid SSL certificate validation issue.
      if ($use_https && strpos($bucket, '.') !== false) {
        $host = self::PRODUCTION_HOST_PATH_FORMAT;
        $path = sprintf('/%s%s', $bucket, $object);
      } else {
        $host = sprintf(self::PRODUCTION_HOST_SUBDOMAIN_FORMAT, $bucket);
        $path = strlen($object) > 0 ? $object : '/';
      }

      $scheme = $use_https ? 'https' : 'http';
    }

    return sprintf('%s://%s%s',
                   $scheme,
                   $host,
                   strtr($path, self::$url_path_translation_map));
  }
public static function getPublicUrl ( $ gs_filename , $ use_https ) { if ( ! is_bool ( $ use_https ) ) { throw new \ InvalidArgumentException ( 'Parameter $use_https must be boolean but was ' . typeOrClass ( $ use_https ) ) ; } if ( ! self :: parseFilename ( $ gs_filename , $ bucket , $ object ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid Google Cloud Storage filename: %s' , htmlspecialchars ( $ gs_filename ) ) ) ; } if ( self :: isDevelServer ( ) ) { $ scheme = 'http' ; $ host = getenv ( 'HTTP_HOST' ) ; $ path = sprintf ( '%s/%s%s' , self :: LOCAL_ENDPOINT , $ bucket , $ object ) ; } else { // Use path format for HTTPS URL when the bucket name contains "." to // avoid SSL certificate validation issue. if ( $ use_https && strpos ( $ bucket , '.' ) !== false ) { $ host = self :: PRODUCTION_HOST_PATH_FORMAT ; $ path = sprintf ( '/%s%s' , $ bucket , $ object ) ; } else { $ host = sprintf ( self :: PRODUCTION_HOST_SUBDOMAIN_FORMAT , $ bucket ) ; $ path = strlen ( $ object ) > 0 ? $ object : '/' ; } $ scheme = $ use_https ? 'https' : 'http' ; } return sprintf ( '%s://%s%s' , $ scheme , $ host , strtr ( $ path , self :: $ url_path_translation_map ) ) ; }
Get the public URL for a Google Cloud Storage filename.

@param string $gs_filename The Google Cloud Storage filename, in the
format gs://bucket_name/object_name.
@param boolean $use_https If True then return a HTTPS URL. Note that the
development server ignores this argument and returns only HTTP URLs.

@return string The public URL.

@throws \InvalidArgumentException if the filename is not in the correct
format or $use_https is not a boolean.
Get the public URL for a Google Cloud Storage filename .