# Upload, process, and download a file

**Flow key:** `upload-process-download`

## Outcome

An authorized user uploads exactly one permitted file, sees truthful scan/processing state, and downloads the correct authorized result without corruption or leakage.

## Actors

- User
- Upload/storage service
- Scanner/processor
- Download/CDN service

## Preconditions and entry points

- Use synthetic non-sensitive files.
- Allowed types/sizes, scan behavior, processing outputs, retention, and download authorization are known.

## Required test data

Use synthetic, isolated, resettable data. Never use real credentials, payment instruments, private customer records, or production notifications.

| Data | Canonical valid seed | Critical variations |
|---|---|---|
| Valid files | `carbon-small.txt`, `carbon-image.png`, `carbon-data.csv` | empty, boundary size, Unicode/emoji name, no/upper extension |
| Invalid files | wrong type and harmless malformed fixture | double extension, MIME mismatch, corrupt/truncated, archive |
| Transfer | single upload | chunked, pause/resume, duplicate, two tabs, slow/offline |
| Processing | known successful transformation | scanner reject, processor timeout, partial output |
| Access | owner | collaborator, revoked user, other tenant, expired signed URL |

## Canonical steps

Treat this as the ordinary successful path inferred from common product behavior. Adapt it to observed labels, business rules, APIs, and implementation evidence; do not invent a requirement.

| Step | User or system action | Expected evidence |
|---:|---|---|
| 1 | Choose or drop a permitted synthetic file. | Name, type, size, preview, and destination are accurate before upload. |
| 2 | Start upload. | Progress corresponds to bytes transferred; cancellation and retry are truthful. |
| 3 | Finalize and scan/process. | One file identity transitions through explicit pending/safe/failed states. |
| 4 | Open metadata/preview. | Stored hash, size, name, owner, version, and derived content match. |
| 5 | Download the original or result. | Authorization is checked and bytes/hash/filename/content type are exact. |
| 6 | Delete/revoke and retry prior links. | Retention and access revocation apply to original, derivatives, caches, and signed URLs. |

## Alternate paths

- Single-part upload
- Chunked/resumable upload
- Drag/drop
- Camera capture
- Server-side import from URL/cloud drive

## Failure and recovery paths

- Disconnect mid-chunk
- Scanner unavailable
- Processor crashes
- Duplicate finalize
- Signed download URL outlives permission

## Completion oracle

- The stated outcome is true in visible UI and authoritative persisted state.
- Exactly one intended business result and no unintended side effect occurred.
- Identity, tenant, authorization, money/data, lifecycle, notifications, integrations, analytics, and audit agree where applicable.
- Refresh, retry, back/forward, and a second authorized read do not reveal a contradictory result.
- Any partial, delayed, canceled, failed, or unknown outcome is labeled truthfully and has a safe recovery path.

## Evidence to capture

- Entry context, actor, tenant, role, feature flags, locale, time zone, and initial identifiers/state.
- Step-level screenshots or DOM state plus request/response, correlation, job, event, and stable business IDs where available.
- Before/after authoritative records, versions, totals, permissions, lifecycle states, and downstream side effects.
- Notifications, audit events, integration deliveries, retries, deduplication, latency, and recovery evidence.
- Untested branches, unsafe-to-run cases, product decisions, and evidence tier.

## Product decisions to resolve

- Exact eligibility, required data, authorization, and validation rules.
- Which steps are synchronous, asynchronous, optional, skippable, reversible, or irreversible.
- Idempotency, concurrency, timeout, retry, cancellation, and compensation semantics.
- Retention, privacy, notification, audit, performance, accessibility, and localization commitments.

## Related CARBON items

- [upload and file input](../../items/content/upload-and-file-input.md)
- [download and export file delivery](../../items/content/download-and-export-file-delivery.md)
- [security](../../items/quality/security.md)
- [resilience and recovery](../../items/quality/resilience-and-recovery.md)

[Back to Productivity and collaboration flows](index.md)
