跳转到主要内容
GET
/
v1
/
files
/
{file_id}
通过ID获取文件元数据
curl --request GET \
  --url https://api.olostep.com/v1/files/{file_id} \
  --header 'Authorization: Bearer <token>'
import requests

url = "https://api.olostep.com/v1/files/{file_id}"

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers)

print(response.text)
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

fetch('https://api.olostep.com/v1/files/{file_id}', 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://api.olostep.com/v1/files/{file_id}",
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://api.olostep.com/v1/files/{file_id}"

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://api.olostep.com/v1/files/{file_id}")
.header("Authorization", "Bearer <token>")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.olostep.com/v1/files/{file_id}")

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
{
  "id": "<string>",
  "object": "<string>",
  "created": 123,
  "filename": "<string>",
  "bytes": 123,
  "purpose": "<string>",
  "status": "<string>"
}

概述

使用此端点,你可以通过文件的唯一标识符(ID)检索文件的元数据。元数据包括文件的名称、大小、创建日期等信息。

请求

HTTP 请求

GET /v1/files/{file_id}

路径参数

  • file_id (string): 需要检索的文件的唯一标识符。

响应

成功的响应将返回一个包含文件元数据的 JSON 对象。

响应示例

{
  "id": "file_123",
  "name": "example.txt",
  "size": 1024,
  "created_at": "2023-01-01T12:00:00Z"
}

错误

如果请求的文件不存在,API 将返回一个错误响应。

错误示例

{
  "error": {
    "code": "file_not_found",
    "message": "The requested file does not exist."
  }
}

相关端点

备注

确保在请求中提供有效的 file_id,否则将无法检索到文件的元数据。

授权

Authorization
string
header
必填

Bearer身份验证头的格式为Bearer ,其中是你的认证令牌。

路径参数

file_id
string
必填

要检索的文件的唯一标识符。

响应

成功响应文件元数据。

id
string

文件 ID

object
string

对象类型。此端点为 "file"。

created
integer

创建的纪元时间戳

filename
string

上传文件的文件名

bytes
integer

文件大小(字节)

purpose
string

文件的用途

status
string

文件状态(例如,“pending”,“completed”)