Skip to content
  • Auto
  • Light
  • Dark

Create Presigned URLs

Create Presigned URLs for Data Source File Upload
client.knowledgeBases.dataSources.createPresignedURLs(DataSourceCreatePresignedURLsParams { files } body?, RequestOptionsoptions?): DataSourceCreatePresignedURLsResponse { request_id, uploads }
post/v2/gen-ai/knowledge_bases/data_sources/file_upload_presigned_urls

To create presigned URLs for knowledge base data source file upload, send a POST request to /v2/gen-ai/knowledge_bases/data_sources/file_upload_presigned_urls.

ParametersExpand Collapse
body: DataSourceCreatePresignedURLsParams { files }
files?: Array<File>

A list of files to generate presigned URLs for.

file_name?: string

Local filename

file_size?: string

The size of the file in bytes.

formatint64
ReturnsExpand Collapse
DataSourceCreatePresignedURLsResponse { request_id, uploads }

Response with pre-signed urls to upload files.

request_id?: string

The ID generated for the request for Presigned URLs.

uploads?: Array<Upload>

A list of generated presigned URLs and object keys, one per file.

expires_at?: string

The time the url expires at.

formatdate-time
object_key?: string

The unique object key to store the file as.

original_file_name?: string

The original file name.

presigned_url?: string

The actual presigned URL the client can use to upload the file directly.

Create Presigned URLs for Data Source File Upload
import Gradient from '@digitalocean/gradient';

const client = new Gradient();

const response = await client.knowledgeBases.dataSources.createPresignedURLs();

console.log(response.request_id);
{
  "request_id": "123e4567-e89b-12d3-a456-426614174000",
  "uploads": [
    {
      "expires_at": "2023-01-01T00:00:00Z",
      "object_key": "example string",
      "original_file_name": "example name",
      "presigned_url": "example string"
    }
  ]
}
Returns Examples
{
  "request_id": "123e4567-e89b-12d3-a456-426614174000",
  "uploads": [
    {
      "expires_at": "2023-01-01T00:00:00Z",
      "object_key": "example string",
      "original_file_name": "example name",
      "presigned_url": "example string"
    }
  ]
}