> ## Documentation Index
> Fetch the complete documentation index at: https://docs.reducto.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Upload

> Upload documents to Reducto using the Go SDK

The `Upload` method uploads files to Reducto's servers and returns a file reference that you can use with other endpoints.

***

## Basic Usage

```go theme={null}
package main

import (
    "context"
    "fmt"
    "io"
    "os"
    
    reducto "github.com/reductoai/reducto-go-sdk"
    "github.com/reductoai/reducto-go-sdk/option"
)

func main() {
    client := reducto.NewClient(option.WithAPIKey(os.Getenv("REDUCTO_API_KEY")))
    
    // Open file
    file, err := os.Open("document.pdf")
    if err != nil {
        fmt.Printf("Error opening file: %v\n", err)
        return
    }
    defer file.Close()
    
    // Upload
    upload, err := client.Upload(context.Background(), reducto.UploadParams{
        File: reducto.F[io.Reader](file),
    })
    if err != nil {
        fmt.Printf("Upload error: %v\n", err)
        return
    }
    
    // Use the file_id in other operations
    fmt.Printf("Uploaded: %s\n", upload.FileID)
}
```

***

## Method Signature

```go theme={null}
func (c *Client) Upload(
    ctx context.Context,
    params UploadParams,
    opts ...option.RequestOption,
) (*shared.Upload, error)
```

### Parameters

| Parameter          | Type                     | Required | Description                                                            |
| ------------------ | ------------------------ | -------- | ---------------------------------------------------------------------- |
| `ctx`              | `context.Context`        | Yes      | Context for cancellation and timeouts                                  |
| `params.File`      | `param.Field[io.Reader]` | No       | The file to upload. Must be wrapped with `reducto.F[io.Reader]()`      |
| `params.Extension` | `param.Field[string]`    | No       | File extension hint (e.g., "pdf"). Usually auto-detected from filename |

### Returns

`*shared.Upload` with the following fields:

* `FileID` (string): The file reference to use with other endpoints (format: `reducto://...`)

***

## Upload Options

### From File

The most common way to upload:

```go theme={null}
file, err := os.Open("invoice.pdf")
if err != nil {
    return err
}
defer file.Close()

upload, err := client.Upload(context.Background(), reducto.UploadParams{
    File: reducto.F[io.Reader](file),
})
```

### With Extension Hint

```go theme={null}
upload, err := client.Upload(context.Background(), reducto.UploadParams{
    File:      reducto.F[io.Reader](file),
    Extension: reducto.F("pdf"), // Useful when filename is missing
})
```

### From Buffer/String

```go theme={null}
import "strings"

// Upload from a string
upload, err := client.Upload(context.Background(), reducto.UploadParams{
    File: reducto.F[io.Reader](strings.NewReader("my file contents")),
})

// With custom filename and content type
upload, err := client.Upload(context.Background(), reducto.UploadParams{
    File: reducto.FileParam(
        strings.NewReader(`{"hello": "foo"}`),
        "file.json",
        "application/json",
    ),
})
```

***

## File Size Limits

* **Direct upload**: Up to 100MB
* **Presigned URLs**: Up to 5GB

For files larger than 100MB, use presigned URLs instead of the upload endpoint.

<Card title="Large File Upload Guide" icon="file-arrow-up" href="/upload/large-files">
  Complete guide to uploading large files using presigned URLs.
</Card>

***

## Error Handling

```go theme={null}
upload, err := client.Upload(context.Background(), reducto.UploadParams{
    File: reducto.F[io.Reader](file),
})
if err != nil {
    // Handle error
    fmt.Printf("Upload failed: %v\n", err)
    return
}
```

Common errors:

* **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

***

## Next Steps

* Learn about [parsing documents](/sdk/go/parse) after upload
* Explore [extracting data](/sdk/go/extract) from uploaded files
* Check out [large file uploads](/upload/large-files) for files > 100MB
