Google Reports API v4即将上传到Google Cloud Storage [英] Google Reports API v4 to be uploaded Google Cloud Storage

查看:73
本文介绍了Google Reports API v4即将上传到Google Cloud Storage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Google Cloud Storage和Google Analytics API v4的新手.

I am new to both Google Cloud Storage and Google Analytics API v4.

我创建了一个helloworld应用程序,在其中添加了JS和CSS文件.我已经在Google存储空间中上传了相同的内容. 但是JS和CSS文件无法正常工作.

I have created a helloworld application where I add JS and CSS files. I have uploaded the same in the google storage. But JS and CSS files are not working.

这是我到目前为止所做的.

  1. 我创建了一个新项目.
  2. 我已经生成了一项新服务,并将下载的JSON文件保留在项目的根目录中.
  3. 我已经创建了一个存储桶.
  4. 我正在使用默认应用引擎.
  1. I have created a new project.
  2. I have generate a new service and keep the downloaded JSON file in the root of the project.
  3. I have created a storage bucket.
  4. I am using default app engine.

我正在使用GCConsole上传项目.上载时,我正在使用具有新属性的旧设置.最后,当我向命令gcloud app console发出命令时,在服务列表中,我没有找到,并且控制台没有要求我提及存储桶.我已经在我的PHP文件中添加了存储桶.在下面,我分享了我的文件.

I am using GCConsole to upload the project. While uploading I am using old settings with new properties. At the end when I give command gcloud app console, in the service list, I do not found and I do not asked by the console to mention the storage bucket. I have add the bucket in my PHP file. Below I have shared my files.

问题

  1. 我已经创建了存储桶,服务JSON文件.我正在使用默认的应用引擎.我有什么想念吗?
  2. 是否可以在VM实例中上传项目并进行测试?
  3. VM实例和App Engine有什么区别?
  4. 如何创建和测试正确的app.yaml文件?
  5. 是否必须在PHP代码中使用和配置存储桶?有其他选择吗?
  6. 我在创建的存储桶下找不到该项目.我在App Engine>源中找到它.在存储桶中,有3个不同的文件夹 是自动创建的.这种方法正确吗?
  7. 是否可以使用用户友好的URL更新项目URL?
  8. 如何在Google Storage中运行Google Reports API v4脚本(PHP,Java)?
  9. 为什么JS和CSS文件不起作用?
  1. I have created storage bucket, service JSON file. I am using default app engine. Is there anything I am missing?
  2. Is it possible to upload the project in VM Instance and test?
  3. What is the difference between VM Instance and App Engine?
  4. How do I create and test proper app.yaml file?
  5. Is it mandatory to use and configure bucket in PHP code? Is there any alternatives?
  6. I do not found the project under the bucket I have created. I found it in App Engine > Source. In the bucket there are 3 different folders are created automatically. Is this approach correct?
  7. Is it possible to update the project URL with user friendly URL?
  8. How can I run Google Reports API v4 scripts (PHP, Java) in Google Storage?
  9. Why JS and CSS files are not working?

项目的文件夹结构

\root\
   \vendor\
   \css\style.css
   \js\main.js
   index.php
   app.yaml
   abcde-9c0e6b4e4b6c.json
   composer.json
   composer.lock
   README.md

index.php

<?php 

require 'vendor/autoload.php';

use Google\Cloud\Storage\StorageClient;
use google\appengine\api\cloud_storage\CloudStorageTools;

$projectId = 'projid';
$bucketId = 'buckid';

$storage = new StorageClient([
    'projectId' => $projectId,
    'keyFilePath' => 'abcde-9c0e6b4e4b6c.json',
]);

$gcsBucket = $storage->bucket($bucketId);
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    <link rel="stylesheet" href="css/style.css">
    <title>GCP PHP</title>
</head>
<body>
    <h1>Welcome to GCP World</h1>
    <div class="p1">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perferendis nihil molestias mollitia iste aliquam placeat quis nobis nesciunt, pariatur ipsa eligendi eveniet ipsam voluptatibus, voluptate eaque alias velit voluptatem id enim sed quisquam praesentium necessitatibus sint. Distinctio nam deleniti, a, eos reprehenderit eligendi, officiis nisi adipisci nostrum et delectus earum.</div>
    <div class="p2">Iure, rerum, inventore! Nulla nesciunt autem, facere eius quas, a ipsum necessitatibus adipisci, reprehenderit eaque fugit debitis dicta voluptates dignissimos quos? Tenetur deleniti impedit excepturi dolorem voluptas, quidem animi ullam! Deserunt eum, modi, eligendi et quam, magni sapiente dolorem porro eaque quibusdam nihil ratione consequuntur amet autem voluptas suscipit, molestiae!</div>
    <div class="p3">Molestias architecto a expedita nostrum, ullam sapiente quia temporibus nesciunt aperiam, asperiores dolor tempore, delectus ipsam sunt? Consequuntur facere reprehenderit nemo voluptatibus ad facilis nostrum temporibus perferendis sequi quasi voluptas, voluptatum repellendus rerum quas repudiandae quidem ipsam eligendi ex numquam sint culpa itaque eum? A saepe deserunt ea asperiores fugiat.</div>
    <div class="footer1"></div>
    <script src="js/main.js"></script>
</body>
</html>

app.yaml

runtime: php73

handlers:
- url: /.*
  script: auto

runtime_config:
    document_root: .

推荐答案

有关可以解决问题的有用信息,请参考文档.

You can refer to the documentation for useful information that might solve your questions.

  1. 创建配置文件以创建JSON配置文件.
  2. 您可以将项目上传到存储桶中,然后创建一个VM实例,然后从那里下载它.但是您将必须创建 部署环境.
  3. App Engine是一种平台即服务,因此基本上您只需在此处进行编码,而平台则是将管理其余部分的平台. Compute Engine是基础架构即服务.你得到你的虚拟机 实例,您将拥有一台实例来管理它,就像您拥有一台计算机一样. 但是,请检查此链接到另一个StackOverflow线程 您可以对此进行进一步的解释.
  4. 要根据yaml语法创建正确的app.yaml文件,您可以转到此页面 http://www .yamllint.com/.创造一个合适的 在用于部署应用程序的Google Cloud Platform中,您可以 有关文档中有关元素的信息 app.yaml配置文件.
  5. 您可以采用多种不同的方式来管理您的存储桶,请在本文档中查看它们是否有上传对象.
  6. 为了回答这个问题,我需要知道您是如何创建存储桶的.
  7. 是的,是的.使用自定义域,您可以更改URL.
  8. 如果您要这样做,则无法从Storage中运行任何内容.
  9. 您缺少处理程序,使用样式表应该是这样的:
  1. Creating config files for creating JSON config files.
  2. You can upload your project into a bucket and create a VM instance and download it from there. But you will have to create the environment for deploying it.
  3. App Engine is a Platform-as-a-Service, so basically you just do code there and the platform is the one that will manage the rest. Compute Engine is a Infrastructure-as-a-Service. You get your VM instance and you are the one that will manage it, as you own computer. However, check this link to another StackOverflow thread where you can have a further explanation about this.
  4. For creating a proper app.yaml file according to yaml syntax, you can go to this page http://www.yamllint.com/. To create a proper one in Google Cloud Platform for deploying your application, you can have the information about the elements in the documentation about app.yaml Configuration File.
  5. You can manage your buckets in many different ways, check them out in this documentation for Uploading objects.
  6. In order to answer that question I would need to know how you created the bucket.
  7. Yes, it is. With a custom domain you can change the URL.
  8. There is no way to run anything from Storage if you meant that.
  9. You are missing the handlers, for using Style Sheets should be like this:

   handlers:
   # Serve a directory as a static resource.
   - url: /stylesheets
     static_dir: stylesheets

这篇关于Google Reports API v4即将上传到Google Cloud Storage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆