Skip to content

File Upload Data Source

Directly upload files

file upload

```python with open('', 'rb') as f: file = client.files.upload_file(upload_file=f) ``` ```Typescript import fs from "fs"

const filePath = “node_modules/llamaindex/examples/abramov.txt”;

file = await client.files.uploadFile(project.id, fs.createReadStream(filePath))

</TabItem>
<TabItem value="curl" label="curl" default>

Step 1: Generate a presigned URL for file upload

Section titled “Step 1: Generate a presigned URL for file upload”

curl -X POST “https://api.cloud.llamaindex.ai/api/v1/files/presigned-url
-H “Content-Type: application/json”
-H “Authorization: Bearer $LLAMA_CLOUD_API_KEY”
-d ’{ “name”: “example.txt” }‘

Step 2: Use the presigned URL to upload the file to S3 within 30 seconds

Section titled “Step 2: Use the presigned URL to upload the file to S3 within 30 seconds”

curl -X PUT “https://your-presigned-url-from-step-1
-H “Content-Type: text/plain”
-F ‘file=@path/to/your/example.txt’

Step 3: Confirm the file upload with LlamaCloud

Section titled “Step 3: Confirm the file upload with LlamaCloud”

curl -X PUT “https://api.cloud.llamaindex.ai/api/v1/files/sync
-H “Content-Type: application/json”
-H “Authorization: Bearer $LLAMA_CLOUD_API_KEY”

</TabItem>
</Tabs>