upload method uploads files to Reducto’s servers and returns a file reference that you can use with other endpoints.
Basic Usage
Method Signature
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
file | Uploadable | null | No | The file to upload. Can be a File, fs.ReadStream, fetch Response, or result of toFile() helper. |
extension | string | null | No | File extension hint (e.g., “pdf”). Usually auto-detected from filename. |
Returns
Promise<Upload> with the following fields:
file_id(string): The file reference to use with other endpoints (format:reducto://...)
Upload Options
From File Stream
The most common way to upload:From Buffer
From File Object
From URL (Presigned URLs)
For large files, you can generate a presigned URL and pass it directly to parse/extract endpoints without uploading:File Size Limits
- Direct upload: Up to 100MB
- Presigned URLs: Up to 5GB
Large File Upload Guide
Complete guide to uploading large files using presigned URLs.
Supported File Types
The SDK accepts any file type that Reducto supports. Common formats include:- Documents: PDF, DOCX, DOC, RTF
- Images: PNG, JPEG, TIFF, BMP
- Spreadsheets: XLSX, XLS, CSV
- Presentations: PPTX, PPT
Supported File Formats
Complete list of supported file formats.
Error Handling
- File not found: The file path doesn’t exist
- File too large: File exceeds 100MB limit (use presigned URLs)
- Invalid file type: File format not supported
- Network error: Connection issues during upload
Examples
Upload and Parse
Batch Upload
Upload with Extension Hint
Best Practices
Use File Streams
Prefer
fs.createReadStream() for large files to avoid loading entire file into memory.Handle Large Files
For files > 100MB, use presigned URLs instead of direct upload.
Reuse File IDs
File IDs can be reused across multiple operations without re-uploading.
Error Handling
Always wrap uploads in try/catch blocks for production code.
Next Steps
- Learn about parsing documents after upload
- Explore extracting data from uploaded files
- Check out large file uploads for files > 100MB