获取文件内容
curl --request GET \
--url https://geekai.co/api/v1/file/{uuid}/content \
--header 'Authorization: Bearer <token>'import requests
url = "https://geekai.co/api/v1/file/{uuid}/content"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://geekai.co/api/v1/file/{uuid}/content', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://geekai.co/api/v1/file/{uuid}/content",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://geekai.co/api/v1/file/{uuid}/content"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://geekai.co/api/v1/file/{uuid}/content")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://geekai.co/api/v1/file/{uuid}/content")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"uuid": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"size": 123,
"type": "<string>",
"md5": "<string>",
"url": "<string>",
"content": "<string>"
}{
"code": "unauthorized",
"message": "Invalid API key or token"
}{
"code": "file_not_found",
"message": "指定的文件不存在"
}{
"code": "invalid_request",
"message": "请求参数不合法"
}文件对话
提取文件内容
GET
/
file
/
{uuid}
/
content
获取文件内容
curl --request GET \
--url https://geekai.co/api/v1/file/{uuid}/content \
--header 'Authorization: Bearer <token>'import requests
url = "https://geekai.co/api/v1/file/{uuid}/content"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://geekai.co/api/v1/file/{uuid}/content', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://geekai.co/api/v1/file/{uuid}/content",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://geekai.co/api/v1/file/{uuid}/content"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://geekai.co/api/v1/file/{uuid}/content")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://geekai.co/api/v1/file/{uuid}/content")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"uuid": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"size": 123,
"type": "<string>",
"md5": "<string>",
"url": "<string>",
"content": "<string>"
}{
"code": "unauthorized",
"message": "Invalid API key or token"
}{
"code": "file_not_found",
"message": "指定的文件不存在"
}{
"code": "invalid_request",
"message": "请求参数不合法"
}文件上传成功后,就可以通过文件提取接口获取文件内容了。需要注意的是,极客智坊提供的是文件异步加载,所以需要轮询提取文件内容接口获取文件内容,直到获取到文件内容为止。
轮询时,可以通过响应数据中的

status 字段判断文件提取状态,status=reading 表示文件正在读取中,status=done 表示文件读取完成,此时可以通过 content 字段值获取文件内容,如果 status=failed,则表示文件读取失败。
cURL 请求示例
curl --location --request GET 'https://geekai.co/api/v1/file/27f9ab4d-137b-4bb3-bcca-ea28f2f89e95/content' \
--header 'Authorization: Bearer {$GEEKAI_API_KEY}'
Postman 请求响应示例

授权
bearerAuthapiKeyAuth
API认证token
路径参数
文件唯一标识符
此页面对您有帮助吗?
⌘I
