Python
import os
from meibel import MeibelClient
client = MeibelClient(api_key=os.environ["MEIBEL_API_KEY"])
with open("product_manual.pdf", "rb") as file:
response = client.datasources.file_uploads.upload_content(
datasource_id="ds_abc123",
file=file,
)
print(f"{response.message} (upload_id={response.upload_id})")
print(f"Stream progress at: {response.sse_url}")import fs from "fs";
import { MeibelClient } from "meibel";
const client = new MeibelClient({ apiKey: process.env.MEIBEL_API_KEY });
const response = await client.datasources.fileUploads.uploadContent(
"ds_8f3a2b1c9d4e",
{
file: fs.createReadStream("./quarterly-report.pdf"),
}
);
console.log(`${response.message} (upload_id: ${response.upload_id})`);
console.log(`Stream progress at: ${response.sse_url}`);package main
import (
"context"
"fmt"
"os"
v2 "github.com/meibel-ai/meibel-go/v2"
)
func main() {
client := v2.NewClient(v2.WithAPIKey(os.Getenv("MEIBEL_API_KEY")))
resp, err := client.Datasources.FileUploads.UploadContent(
context.Background(),
"datasource_abc123",
v2.BodyUploadContent{},
)
if err != nil {
panic(err)
}
fmt.Printf("Upload accepted: %s (upload_id: %s)\n", resp.Message, resp.UploadId)
fmt.Printf("Track progress via SSE: %s\n", resp.SseUrl)
}curl --request POST \
--url https://api.meibel.ai/v2/datasources/{datasource_id}/content \
--header 'Content-Type: multipart/form-data' \
--header 'Meibel-API-Key: <api-key>' \
--form 'files=<string>' \
--form files.items='@example-file'const form = new FormData();
form.append('files', '<string>');
form.append('files.items', '{
"fileName": "example-file"
}');
const options = {method: 'POST', headers: {'Meibel-API-Key': '<api-key>'}};
options.body = form;
fetch('https://api.meibel.ai/v2/datasources/{datasource_id}/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://api.meibel.ai/v2/datasources/{datasource_id}/content",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"files\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"files.items\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Content-Type: multipart/form-data; boundary=---011000010111000001101001",
"Meibel-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://api.meibel.ai/v2/datasources/{datasource_id}/content")
.header("Meibel-API-Key", "<api-key>")
.header("Content-Type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"files\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"files.items\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.meibel.ai/v2/datasources/{datasource_id}/content")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Meibel-API-Key"] = '<api-key>'
request["Content-Type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"files\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"files.items\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "<string>",
"datasource_id": "<string>",
"upload_id": "<string>",
"sse_url": "<string>",
"estimated_files": 123,
"estimated_size": 123
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}File uploads
Upload Content (async)
POST
/
datasources
/
{datasource_id}
/
content
Python
import os
from meibel import MeibelClient
client = MeibelClient(api_key=os.environ["MEIBEL_API_KEY"])
with open("product_manual.pdf", "rb") as file:
response = client.datasources.file_uploads.upload_content(
datasource_id="ds_abc123",
file=file,
)
print(f"{response.message} (upload_id={response.upload_id})")
print(f"Stream progress at: {response.sse_url}")import fs from "fs";
import { MeibelClient } from "meibel";
const client = new MeibelClient({ apiKey: process.env.MEIBEL_API_KEY });
const response = await client.datasources.fileUploads.uploadContent(
"ds_8f3a2b1c9d4e",
{
file: fs.createReadStream("./quarterly-report.pdf"),
}
);
console.log(`${response.message} (upload_id: ${response.upload_id})`);
console.log(`Stream progress at: ${response.sse_url}`);package main
import (
"context"
"fmt"
"os"
v2 "github.com/meibel-ai/meibel-go/v2"
)
func main() {
client := v2.NewClient(v2.WithAPIKey(os.Getenv("MEIBEL_API_KEY")))
resp, err := client.Datasources.FileUploads.UploadContent(
context.Background(),
"datasource_abc123",
v2.BodyUploadContent{},
)
if err != nil {
panic(err)
}
fmt.Printf("Upload accepted: %s (upload_id: %s)\n", resp.Message, resp.UploadId)
fmt.Printf("Track progress via SSE: %s\n", resp.SseUrl)
}curl --request POST \
--url https://api.meibel.ai/v2/datasources/{datasource_id}/content \
--header 'Content-Type: multipart/form-data' \
--header 'Meibel-API-Key: <api-key>' \
--form 'files=<string>' \
--form files.items='@example-file'const form = new FormData();
form.append('files', '<string>');
form.append('files.items', '{
"fileName": "example-file"
}');
const options = {method: 'POST', headers: {'Meibel-API-Key': '<api-key>'}};
options.body = form;
fetch('https://api.meibel.ai/v2/datasources/{datasource_id}/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://api.meibel.ai/v2/datasources/{datasource_id}/content",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"files\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"files.items\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Content-Type: multipart/form-data; boundary=---011000010111000001101001",
"Meibel-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://api.meibel.ai/v2/datasources/{datasource_id}/content")
.header("Meibel-API-Key", "<api-key>")
.header("Content-Type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"files\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"files.items\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.meibel.ai/v2/datasources/{datasource_id}/content")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Meibel-API-Key"] = '<api-key>'
request["Content-Type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"files\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"files.items\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "<string>",
"datasource_id": "<string>",
"upload_id": "<string>",
"sse_url": "<string>",
"estimated_files": 123,
"estimated_size": 123
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Authorizations
Path Parameters
Body
multipart/form-data
One or more files to upload
Response
Successful Response
Result of an async upload — files are accepted and streamed asynchronously.
True if the upload was accepted for processing
Human-readable status message
ID of the datasource the files were uploaded to (created on the fly if name was supplied)
Identifier for this upload batch — use with the SSE stream to track progress
Server-sent-events URL to stream upload progress until 'stream_complete'
Number of files the server expects to process for this upload
Total estimated size of the upload in bytes
Was this page helpful?
⌘I