跳转到主要内容
POST
/
v1
/
files
/
{file_id}
/
complete
完成文件上传
curl --request POST \
  --url https://api.olostep.com/v1/files/{file_id}/complete \
  --header 'Authorization: Bearer <token>'
{
  "id": "<string>",
  "object": "<string>",
  "created": 123,
  "filename": "<string>",
  "bytes": 123,
  "purpose": "<string>",
  "status": "<string>"
}

完成文件上传

在上传文件后,你需要调用此端点来完成上传过程。此操作将验证文件是否存在,检查其JSON格式是否有效,并将文件状态更新为已完成。

请求

方法: POST 路径: /v1/files/{file_id}/complete

路径参数

  • file_id: 要完成上传的文件的唯一标识符。

响应

成功调用此端点后,你将收到一个确认响应,表示文件上传已成功完成。

示例

import { useState } from 'react';
import { completeFileUpload } from 'olostep-sdk';

function CompleteUploadButton({ fileId }) {
  const [status, setStatus] = useState('pending');

  const handleCompleteUpload = async () => {
    try {
      await completeFileUpload(fileId);
      setStatus('completed');
    } catch (error) {
      setStatus('error');
    }
  };

  return (
    <button onClick={handleCompleteUpload}>
      {status === 'pending' ? '完成上传' : status === 'completed' ? '上传完成' : '上传失败'}
    </button>
  );
}

注意事项

  • 确保在调用此端点之前,文件已完全上传。
  • 验证文件的JSON格式,以避免格式错误导致的上传失败。

授权

Authorization
string
header
必填

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

路径参数

file_id
string
必填

要完成的文件的唯一标识符。

响应

文件上传成功完成。

id
string

文件 ID

object
string

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

created
integer

创建的纪元时间戳

filename
string

上传文件的文件名

bytes
integer

文件大小(字节)

purpose
string

文件的用途

status
string

文件状态。成功完成后将为“completed”。