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

    $gs_filename = sprintf('/gs/%s%s', $bucket, $object);

    $request = new CreateEncodedGoogleStorageKeyRequest();
    $response = new CreateEncodedGoogleStorageKeyResponse();

    $request->setFilename($gs_filename);

    try {
      ApiProxy::makeSyncCall('blobstore',
                             'CreateEncodedGoogleStorageKey',
                             $request,
                             $response);
    } catch (ApplicationError $e) {
      throw self::applicationErrorToException($e);
    }

    return $response->getBlobKey();
  }