2

我想importRows融合表https://developers.google.com/fusiontables/docs/v1/reference/table/importRows如何附上importrows文件 - 融合表

我使用谷歌的API的PHP客戶端並沒有什麼有關文件(見下文)的文件。 如何附加文件?

/** 
    * 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"); 
    } 

回答

0

正如你可以see in the documentatioňimportRows節選你上傳文件要導入:

此方法支持的/上傳URI,並接受上載的媒體與 以下特點:

  • 最大文件大小:100MB
  • Acc epted媒體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。

Thereareseveral教程,告訴你如何用PHP做到這一點。

+0

但我想用google-api-php-client – piernik