api.files

list()

api.files.list() → Promise<File[]>

Cada file del conto, come records simples. Nessun contenuto, nessun limite de dimensione del call — questo è l'inventari.

GET /api/filesfreean array
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

Retorno

[
  {
    id: "…",
    name: "report.md",
    category: "document",
    mimeType: "text/markdown",
    size: 2048,
    storageId: "…",
    status: "done",
    createdAt: "2026-10-07T11:02:08.400Z"
  }
]
[
    {
        "id": "…",
        "name": "report.md",
        "category": "document",
        "mimeType": "text/markdown",
        "size": 2048,
        "storageId": "…",
        "status": "done",
        "createdAt": "2026-10-07T11:02:08.400Z",
    }
]
idstring

- Ce? (), update() e delete() a tè.

namestring

Come tu lo chiamî.

categorystring

image · data · document · video · audio.

mimeTypestring

Il tipo con cui era salvat.

sizeinteger

Bytes. Lee questo prima de agatching algo grande.

storageIdstring

Quale stoccatura lo detiene.

statusstring

done quando è là.

createdAtstring

Quando fu salvat.

Un array, direttamente — non un envelope. Il contenuto non è in esso: questo call sta a cheap quanta quanti files ha, e lects uno è get().

Retorna tutto

Non c'è limite e cursor, quindi un conto con migliaia di files risponde con migliaia. Filtra e trie da tuos lati.

const files = await api.files.list();

// What is actually taking the space
const heaviest = [...files].sort((a, b) => b.size - a.size).slice(0, 10);

// How much, in total and per storage
const total = files.reduce((sum, f) => sum + (f.size || 0), 0);

const perStorage = new Map();
for (const f of files) {
  perStorage.set(f.storageId, (perStorage.get(f.storageId) || 0) + (f.size || 0));
}
from collections import Counter

files = api.files.list()

# What is actually taking the space
heaviest = sorted(files, key=lambda f: f.get("size") or 0, reverse=True)[:10]

# How much, in total and per storage
total = sum(f.get("size") or 0 for f in files)

per_storage = Counter()
for f in files:
    per_storage[f["storageId"]] += f.get("size") or 0

A prelegere una da lere

const files = await api.files.list();

const latest = files
  .filter((f) => f.category === "document")
  .sort((a, b) => Date.parse(b.createdAt) - Date.parse(a.createdAt))[0];

const file = await api.files.get(latest.id);
files = api.files.list()

latest = max((f for f in files if f["category"] == "document"), key=lambda f: f["createdAt"])

file = api.files.get(latest["id"])
I nomi non sono unici

Salvando due doubo sotto un nome da due files. Match on id, e tratât il nome come un label per le persone.

Un assegn-up che è sicuro da run

const files = await api.files.list();
const month = Date.now() - 30 * 24 * 60 * 60 * 1000;

const temporary = files.filter(
  (f) => f.name.startsWith("tmp-") && Date.parse(f.createdAt) < month,
);

for (const f of temporary) await api.files.delete(f.id);
from datetime import datetime, timedelta, timezone

files = api.files.list()
month = datetime.now(timezone.utc) - timedelta(days=30)

temporary = [f for f in files
             if f["name"].startswith("tmp-")
             and datetime.fromisoformat(f["createdAt"].replace("Z", "+00:00")) < month]

for f in temporary:
    api.files.delete(f["id"])

Restrittura da qualcosa che tu controli — un prefijo di tuo proprio codice scrie — piuttosto que solo per l'età. L'età non è un segnale che un file è terminat con.