Skip to content

Use cases and traces

Each file knows which use case uploaded it, each case says which buckets it uses, and every upload is a step in the case's trace.

Applies to EngineCloud
View as Markdown
On this page
  1. Saying the case
  2. What is recorded
  3. The case says which buckets it uses
  4. In the trace

A file in your app is always there because someone did something: a customer uploaded a photo, an order made its receipt. Files records which use case of your map did it, so you can answer «where did this file come from?» and «which files does this case create?».

Saying the case

TypeScript
await files.bucket('receipts').upload('order-1042.pdf', pdf, { case: 'place-order' });

or the header Sypnia-Case: place-order on any request to the API: uploads, replacements, deletes and signed links. The id is the one in your map, from cases/<area>/<id>.case.yaml (Cases).

When your server is traced with Telemetry’s SDK, the case of the current request is already known: @sypnia/files reads it and sends the trace along, so you can leave case out.

What is recorded

WhereWhat
sypnia_files.objects.casethe case that last wrote the file; null when none was given
the audit logthe case of every write and delete made with a secret or S3 key

Because the case is a column, you can query it like any other: «every receipt place-order wrote this week», «files no case owns».

The case says which buckets it uses

cases/orders/place-order.case.yaml
id: place-order
title: Place an order
actor: customer
files:
  reads: [menu]
  writes: [receipts]

The Cases check compares that with what really happens: a case that writes a bucket it does not list, or lists one it never uses, is reported, the same way as a table the case did not declare.

In the trace

Each call is a step (a span) inside the trace of its case, next to the database queries and the page that started it:

SpanWhat it carries
files.upload <bucket>the size, the content type, whether it was resumable, the time it took
files.download <bucket>, files.transform <bucket>the size served, whether it came from the CDN’s cache
files.sign <bucket>, files.delete <bucket>the bucket and how long the link lasts

No span carries the file’s contents. With Sypnia Telemetry, a slow upload shows up in the case where a person was waiting, and in Sypnia Cases each case lists its buckets and how many files it wrote.

  1. Saying the case
  2. What is recorded
  3. The case says which buckets it uses
  4. In the trace

    Search pages, sections and terms