【问题标题】:How to attach file in importrows - fusion tables如何在 importrows 中附加文件 - 融合表
【发布时间】:2014-02-28 13:14:27
【问题描述】:

我想importRows到融合表https://developers.google.com/fusiontables/docs/v1/reference/table/importRows

我正在使用 google-api-php-client 并且文档中没有关于文件的内容(如下)。 如何附加文件?

 /**
   * Import more rows into a table. (table.importRows)
   *
   * @param string $tableId
   * The table into which new rows are being imported.
   * @param array $optParams Optional parameters.
   *
   * @opt_param int startLine
   * The index of the first line from which to start importing, inclusive. Default is 0.
   * @opt_param bool isStrict
   * Whether the CSV must have the same number of values for each row. If false, rows with fewer
    * values will be padded with empty values. Default is true.
   * @opt_param string encoding
   * The encoding of the content. Default is UTF-8. Use 'auto-detect' if you are unsure of the
    * encoding.
   * @opt_param string delimiter
   * The delimiter used to separate cell values. This can only consist of a single character. Default
    * is ','.
   * @opt_param int endLine
   * The index of the last line from which to start importing, exclusive. Thus, the number of
    * imported lines is endLine - startLine. If this parameter is not provided, the file will be
    * imported until the last line of the file. If endLine is negative, then the imported content will
    * exclude the last endLine lines. That is, if endline is negative, no line will be imported whose
    * index is greater than N + endLine where N is the number of lines in the file, and the number of
    * imported lines will be N + endLine - startLine.
   * @return Google_Service_Fusiontables_Import
   */
  public function importRows($tableId, $optParams = array())
  {
    $params = array('tableId' => $tableId);
    $params = array_merge($params, $optParams);
    return $this->call('importRows', array($params), "Google_Service_Fusiontables_Import");
  }

【问题讨论】:

    标签: php google-api google-fusion-tables google-api-php-client


    【解决方案1】:

    您可以see in the documentation importRows 除了您上传要导入的文件:

    此方法支持 /upload URI 并接受上传的媒体 具有以下特点:

    • 最大文件大小:100MB
    • 接受的媒体 MIME 类型:application/octet-stream

    此方法通过两个独立的 URI。更多详情,请参阅媒体上传文档。

    • 上传 URI,用于媒体上传请求:POST https://www.googleapis.com/upload/fusiontables/v1/tables/tableId/import
    • 元数据 URI,仅用于元数据请求:POST https://www.googleapis.com/fusiontables/v1/tables/tableId/import

    现在您只需将文件上传到相应的 URL。

    There are several 向您展示如何使用 PHP 进行此操作的教程。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-13
      • 2018-01-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多