Skip to main content

Upload File

Upload a file for accident reconstruction processing. Files must be associated with a case and assigned to either the plaintiff or defendant vehicle.

File Size Limit

Maximum file size is 50MB. Files exceeding this limit will be rejected with an INVALID_ARGUMENT error.

Parameters

ParameterTypeRequiredDescription
contentbytesYesFile content as binary data (max 50MB)
filenamestringYesOriginal filename with extension
purposestringYesFile purpose (see table below)
caseIdstringYesCase ID to associate the file with
mimeTypestringNoMIME type (auto-detected if not provided)

File Purpose Values

The purpose field specifies the file type and which party it belongs to:

Purpose ValueDescriptionAccepted Types
vehicle_photoVehicle damage photosImages
edr_documentEvent Data Recorder reportPDF only
tcr_documentTraffic Collision ReportPDF

Use vehicle_role (plaintiff or defendant) to specify which vehicle. Defaults to plaintiff.

Traffic Collision Reports

Upload TCR PDFs with file_category=tcr_document. The system automatically extracts accident metadata during report generation.

Response

Returns:

  • fileId: Unique file identifier for use in accident reconstruction reports

Examples

Upload Plaintiff Vehicle Photo

import (
"context"
"os"
"github.com/silentwitness/go-sdk"
)

fileBytes, err := os.ReadFile("plaintiff-front-damage.jpg")
if err != nil {
log.Fatal(err)
}

silentwitness.Key = "sk_test_..."
response, err := silentwitness.Files.Upload(ctx, &silentwitness.UploadFileRequest{
Content: fileBytes,
Filename: "plaintiff-front-damage.jpg",
Purpose: "vehicle_photo",
CaseId: "case_abc123",
})
if err != nil {
log.Fatal(err)
}

fmt.Printf("File ID: %s\n", response.FileId)

Upload EDR Report

import "github.com/silentwitness/go-sdk"

edrData, err := os.ReadFile("edr-report.pdf")
if err != nil {
log.Fatal(err)
}

silentwitness.Key = "sk_test_..."
response, err := silentwitness.Files.Upload(ctx, &silentwitness.UploadFileRequest{
Content: edrData,
Filename: "edr-report.pdf",
Purpose: "edr_document",
CaseId: "case_abc123",
})

File Limits & Requirements

Size Limit

  • Maximum file size: 50MB (52,428,800 bytes)
  • Files larger than 50MB will be rejected immediately
  • The API validates file size before processing

Supported File Types

  • Images: JPEG, PNG, WebP
  • Documents: PDF, DOC, DOCX, CSV
  • Other formats: Accepted based on MIME type detection

Best Practices

  • Compress large images before upload to stay under the 50MB limit
  • Use standard image formats (JPEG, PNG) for crash photos
  • Include descriptive filenames for easier identification
  • Upload files immediately after creating a case

Usage Steps

  1. Create a case using the Cases API
  2. Upload photos for plaintiff vehicle with vehicle_photo purpose
  3. Upload photos for defendant vehicle (if applicable) with vehicle_photo purpose and vehicle_role=defendant
  4. Upload EDR (if available) with edr_document purpose
  5. Upload TCR (if available) with tcr_document purpose
  6. Generate report using the Cases API

Errors

CodeDescription
INVALID_ARGUMENTInvalid file, parameters, purpose, or file too large
NOT_FOUNDCase ID not found
PERMISSION_DENIEDNo access to specified case
UNAUTHENTICATEDInvalid or missing API key