Как прикрепить файл в 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");
  }

person piernik    schedule 28.02.2014    source источник


Ответы (1)


Как вы можете увидеть в документацииn importRows за исключением того, что вы < strong>загрузите файл, который хотите импортировать:

Этот метод поддерживает URI /upload и принимает загруженные носители со следующими характеристиками:

  • Максимальный размер файла: 100 МБ.
  • Допустимые типы 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-адресу.

здесь несколько руководств, в которых показано, как это сделать с помощью PHP.

person Odi    schedule 04.03.2014