---
title: "nuxt-backend/storage"
description: "Every export of nuxt-backend/storage, with its signature and where it is defined."
canonical_url: "https://nuxt-backend.dev/docs/reference/api/storage"
---
# nuxt-backend/storage

Version: nuxt-backend 0.6.x · Tab: Reference · Kind: reference · Status: stable

Every page: [llms.txt](https://nuxt-backend.dev/llms.txt) · Skill for coding agents: [nuxt-backend](https://nuxt-backend.dev/.well-known/skills/nuxt-backend/SKILL.md)

Commands use npm; use your project's package manager.

## Interfaces

### FileOwner

Defined in: [src/convex/integrations/storage.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts)

Who owns a file: the account, and the workspace whose members read it.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="userid">
        
      </a>
      
       <code>
        userId
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="workspaceid">
        
      </a>
      
       <code>
        workspaceId?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The workspace the file belongs to: every member reads it, and it stays when the uploader leaves. Absent for a file of the account's own.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### StoredFile

Defined in: [src/convex/integrations/storage.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts)

What `storage.store` kept.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="storageid">
        
      </a>
      
       <code>
        storageId
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The file's id, in the <code>
        backend
      </code>
      
       component's storage: store it as <code>
        v.string()
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="size">
        
      </a>
      
       <code>
        size
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      Its size in bytes, after stripping.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="contenttype">
        
      </a>
      
       <code>
        contentType
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The type read from its bytes.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### ResolvedShareLink

Defined in: [src/convex/integrations/storage.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts)

A share link a public page resolved: the row, who shared it, and its preview card's image.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="id">
        
      </a>
      
       <code>
        id
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The shared row's id.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="sharedby">
        
      </a>
      
       <code>
        sharedBy
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The account that turned the link on.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="ogimageurl">
        
      </a>
      
       <code>
        ogImageUrl
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
       | <code>
        null
      </code>
    </td>
    
    <td>
      An expiring URL (seven days) of the <code>
        ogImage
      </code>
      
       file, for the page's <code>
        og:image
      </code>
      
      ; <code>
        null
      </code>
      
       without one.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### ShareLinkState

Defined in: [src/convex/integrations/storage.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts)

A row's share link as its page reads it.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="sharedat">
        
      </a>
      
       <code>
        sharedAt
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      When the link was turned on, epoch ms.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### MintedShareLink

Defined in: [src/convex/integrations/storage.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts)

A link just minted: its token and the URL built from it, shown once.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="token">
        
      </a>
      
       <code>
        token
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="url">
        
      </a>
      
       <code>
        url
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### StorageApi

Defined in: [src/convex/integrations/storage.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts)

The functions `backend/storage.ts` re-exports.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="generateuploadurl">
        
      </a>
      
       <code>
        generateUploadUrl
      </code>
    </td>
    
    <td>
      <code>
        RegisteredMutation
      </code>
      
      <<code>
        "public"
      </code>
      
      , <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, <code>
        Promise
      </code>
      
      <<code>
        string
      </code>
      
      >>
    </td>
    
    <td>
      A one-time upload URL into the component's storage, for a signed-in account, at the <code>
        upload
      </code>
      
       rate.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="getfileurl">
        
      </a>
      
       <code>
        getFileUrl
      </code>
    </td>
    
    <td>
      <code>
        RegisteredQuery
      </code>
      
      <<code>
        "public"
      </code>
      
      , { <code>
        storageId
      </code>
      
      : <code>
        Id
      </code>
      
      <<code>
        "_storage"
      </code>
      
      >; }, <code>
        Promise
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      >>
    </td>
    
    <td>
      A file's URL for its owner and the members of its workspace; <code>
        null
      </code>
      
       for anyone else, and while it is checked. Typed with a storage id, as <code>
        <StorageImage :get-url>
      </code>
      
       takes it.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="getsharelink">
        
      </a>
      
       <code>
        getShareLink
      </code>
    </td>
    
    <td>
      <code>
        RegisteredQuery
      </code>
      
      <<code>
        "public"
      </code>
      
      , { <code>
        table
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        id
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        Promise
      </code>
      
      <<a href="#sharelinkstate">
        <code>
          ShareLinkState
        </code>
      </a>
      
       | <code>
        null
      </code>
      
      >>
    </td>
    
    <td>
      Whether a row has a live share link, and since when; <code>
        null
      </code>
      
       without one, or for a caller who may not share it.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="enablesharelink">
        
      </a>
      
       <code>
        enableShareLink
      </code>
    </td>
    
    <td>
      <code>
        RegisteredMutation
      </code>
      
      <<code>
        "public"
      </code>
      
      , { <code>
        table
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        id
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        Promise
      </code>
      
      <<a href="#mintedsharelink">
        <code>
          MintedShareLink
        </code>
      </a>
      
      >>
    </td>
    
    <td>
      Turn a row's link on, replacing any earlier one: the token and the URL, shown once.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="revokesharelink">
        
      </a>
      
       <code>
        revokeShareLink
      </code>
    </td>
    
    <td>
      <code>
        RegisteredMutation
      </code>
      
      <<code>
        "public"
      </code>
      
      , { <code>
        table
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        id
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        Promise
      </code>
      
      <<code>
        null
      </code>
      
      >>
    </td>
    
    <td>
      Turn a row's link off.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### StorageReadCtx

Defined in: [src/convex/integrations/storage.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts)

A context that reads: any query, mutation or action.

#### Extended by

- [`StorageWriteCtx`](#storagewritectx)

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="runquery">
        
      </a>
      
       <code>
        runQuery
      </code>
    </td>
    
    <td>
      <<code>
        Query
      </code>
      
      >(<code>
        query
      </code>
      
      , ...<code>
        args
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        FunctionReturnType
      </code>
      
      <<code>
        Query
      </code>
      
      >>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="auth">
        
      </a>
      
       <code>
        auth?
      </code>
    </td>
    
    <td>
      <code>
        Auth
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### StorageWriteCtx

Defined in: [src/convex/integrations/storage.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts)

A context that writes: a mutation (or an action, which is no transaction).

#### Extends

- [`StorageReadCtx`](#storagereadctx)

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Inherited from
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="runquery-1">
        
      </a>
      
       <code>
        runQuery
      </code>
    </td>
    
    <td>
      <<code>
        Query
      </code>
      
      >(<code>
        query
      </code>
      
      , ...<code>
        args
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        FunctionReturnType
      </code>
      
      <<code>
        Query
      </code>
      
      >>
    </td>
    
    <td>
      <a href="#storagereadctx">
        <code>
          StorageReadCtx
        </code>
      </a>
      
      .<a href="#runquery">
        <code>
          runQuery
        </code>
      </a>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="auth-1">
        
      </a>
      
       <code>
        auth?
      </code>
    </td>
    
    <td>
      <code>
        Auth
      </code>
    </td>
    
    <td>
      <a href="#storagereadctx">
        <code>
          StorageReadCtx
        </code>
      </a>
      
      .<a href="#auth">
        <code>
          auth
        </code>
      </a>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="runmutation">
        
      </a>
      
       <code>
        runMutation
      </code>
    </td>
    
    <td>
      <<code>
        Mutation
      </code>
      
      >(<code>
        mutation
      </code>
      
      , ...<code>
        args
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        FunctionReturnType
      </code>
      
      <<code>
        Mutation
      </code>
      
      >>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### EnabledShareLink

Defined in: [src/convex/integrations/storage.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts)

What `onEnable` learns about the link it follows.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="url-1">
        
      </a>
      
       <code>
        url
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The link, as <code>
        enableShareLink
      </code>
      
       returns it to the caller: a bearer secret, opening the row to anyone who holds it. Hand it on (an email to the author, say), never store or log it: the package keeps only its hash, so a copy in a table or a log is what would leak it.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="rotated">
        
      </a>
      
       <code>
        rotated
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      Whether it replaced a live link, which stopped working.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### ShareableOptions

Defined in: [src/convex/integrations/storage.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts)

How a table's rows are shared, for [Storage.shareable](#shareable).

#### Type Parameters

<table>
<thead>
  <tr>
    <th>
      Type Parameter
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="type-parameter-dm-2">
        
      </a>
      
       <code>
        DM
      </code>
      
       <em>
        extends
      </em>
      
       <code>
        GenericDataModel
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="type-parameter-t">
        
      </a>
      
       <code>
        T
      </code>
      
       <em>
        extends
      </em>
      
       <code>
        TableNamesInDataModel
      </code>
      
      <<code>
        DM
      </code>
      
      >
    </td>
  </tr>
</tbody>
</table>

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="path">
        
      </a>
      
       <code>
        path
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      Where the public page lives: a link reads <code>
        SITE_URL
      </code>
      
       + <code>
        path
      </code>
      
       + <code>
        /
      </code>
      
       + the token.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="canshare">
        
      </a>
      
       <code>
        canShare
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        row
      </code>
      
      ) => <code>
        boolean
      </code>
      
       | <code>
        Promise
      </code>
      
      <<code>
        boolean
      </code>
      
      >
    </td>
    
    <td>
      Whether the signed-in caller may turn the row's link on or rotate it. The same answer lets someone other than the one who shared it see that the link is on, and take it offline. <strong>
        Guarantee
      </strong>
      
       - Runs: in <code>
        enableShareLink
      </code>
      
      's and <code>
        revokeShareLink
      </code>
      
      's mutations and in <code>
        getShareLink
      </code>
      
      's query, in their transaction, with the signed-in caller as <code>
        ctx.user
      </code>
      
       - Delivery: once per <code>
        enableShareLink
      </code>
      
      ; in <code>
        revokeShareLink
      </code>
      
       and <code>
        getShareLink
      </code>
      
       only when the row has a live link and the caller is not the one who shared it. A live <code>
        getShareLink
      </code>
      
       runs it again whenever what it read changes - Order: <code>
        enableShareLink
      </code>
      
       asks it after the caller is checked (signed in, account present, not banned) and the row is found (a missing row fails <code>
        invalid_input
      </code>
      
       first), before the link is written; <code>
        revokeShareLink
      </code>
      
       after the same caller check and the link read; <code>
        getShareLink
      </code>
      
       after the link read, with only the signed-in identity checked - When it throws: <code>
        enableShareLink
      </code>
      
       and <code>
        revokeShareLink
      </code>
      
       fail with its error and change nothing; <code>
        getShareLink
      </code>
      
       reads a throw, a missing row included, as <code>
        false
      </code>
      
       and answers <code>
        null
      </code>
      
       - Idempotency: a check: it may run many times for one row and caller, and writes nothing
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="ogimage">
        
      </a>
      
       <code>
        ogImage?
      </code>
    </td>
    
    <td>
      (<code>
        row
      </code>
      
      ) => <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
       | <code>
        undefined
      </code>
    </td>
    
    <td>
      The storage id of the image the preview card shows, or <code>
        null
      </code>
      
       for none. <strong>
        Guarantee
      </strong>
      
       - Runs: in <code>
        resolveShareLink
      </code>
      
      , inside the query or mutation of yours that calls it, once the token matched a live link and its row was found; never from an action - Delivery: once per resolve; a live query that resolves the link runs it again whenever what it read changes - Order: after the link and its row are read, before the image's expiring URL is signed - When it throws: <code>
        resolveShareLink
      </code>
      
       throws, and with it the function of yours that called it - Idempotency: synchronous and given only the row: it may run many times for one row, and should read nothing else
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="onenable">
        
      </a>
      
       <code>
        onEnable?
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        row
      </code>
      
      , <code>
        link
      </code>
      
      ) => <code>
        void
      </code>
      
       | <code>
        Promise
      </code>
      
      <<code>
        void
      </code>
      
      >
    </td>
    
    <td>
      Runs in <code>
        enableShareLink
      </code>
      
      's mutation once the link is on, a new one replacing an earlier one included: record an event, tick off a checklist step, stamp the row. A throw rolls the link back with it. <code>
        link.url
      </code>
      
       is the live secret: never store or log it. <strong>
        Guarantee
      </strong>
      
       - Runs: in <code>
        enableShareLink
      </code>
      
      's mutation, in its transaction, with the caller who turned the link on as <code>
        ctx.user
      </code>
      
       - Delivery: once per <code>
        enableShareLink
      </code>
      
       that succeeds; each rotation is a call of its own, with <code>
        link.rotated
      </code>
      
       set - Order: after <code>
        canShare
      </code>
      
       agreed and the new link replaced any earlier one, before the mutation returns the link - When it throws: the mutation fails with its error and rolls back with it: no new link, and an earlier one stays live - Idempotency: its writes commit with the link or not at all; a conflict reruns the whole mutation, never this hook alone
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### UploadSafety

Defined in: [src/convex/integrations/storage.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts)

The content check [Storage.acceptUpload](#acceptupload) runs: the app's `ai`, from `setupAi`.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="requiresafe">
        
      </a>
      
       <code>
        requireSafe
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        input
      </code>
      
      , <code>
        about?
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        void
      </code>
      
      >
    </td>
    
    <td>
      <code>
        ai.requireSafe
      </code>
      
      : refuses an image the moderation policy blocks, <code>
        invalid_input
      </code>
      
       with reason <code>
        content_blocked
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### AcceptUploadOptions

Defined in: [src/convex/integrations/storage.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts)

What [Storage.acceptUpload](#acceptupload) runs around the content check: your check first, your keep last.

#### Type Parameters

<table>
<thead>
  <tr>
    <th>
      Type Parameter
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="type-parameter-kept">
        
      </a>
      
       <code>
        Kept
      </code>
    </td>
  </tr>
</tbody>
</table>

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="check">
        
      </a>
      
       <code>
        check?
      </code>
    </td>
    
    <td>
      () => <code>
        boolean
      </code>
      
       | <code>
        void
      </code>
      
       | <code>
        Promise
      </code>
      
      <<code>
        boolean
      </code>
      
       | <code>
        void
      </code>
      
       | <code>
        null
      </code>
      
      > | <code>
        null
      </code>
    </td>
    
    <td>
      Your check that the upload may go where it is headed, before the content check reads it: the caller's row, room on it, not a file kept already. A check that refuses here costs no classifier call. Refuse by throwing, or by returning <code>
        false
      </code>
      
      , which refuses the upload as <code>
        invalid_input
      </code>
      
       on <code>
        file
      </code>
      
      ; pass by returning nothing, <code>
        null
      </code>
      
       or <code>
        true
      </code>
      
      . A query that returns a row doesn't type as a check, since the row is never read: wrap it, <code>
        check: async () => { await ctx.runQuery(…) }
      </code>
      
      . <strong>
        Guarantee
      </strong>
      
       - Runs: in the action that calls <code>
        acceptUpload
      </code>
      
      , through the <code>
        ctx
      </code>
      
       your callback closed over (an internal query of yours, a rate limit) - Delivery: once per <code>
        acceptUpload
      </code>
      
      ; a person's retry calls <code>
        acceptUpload
      </code>
      
       again, and with it this - Order: first, before the content check and <code>
        keep
      </code>
      
       - When it throws: <code>
        acceptUpload
      </code>
      
       throws its error, and neither the content check nor <code>
        keep
      </code>
      
       runs; an <code>
        invalid_input
      </code>
      
       on <code>
        file
      </code>
      
       or <code>
        images
      </code>
      
      , or a <code>
        quota_exceeded
      </code>
      
      , discards the upload, any other error keeps it for a retry. A check that returns <code>
        false
      </code>
      
       is refused as <code>
        invalid_input
      </code>
      
       on <code>
        file
      </code>
      
      , so the upload is discarded - Idempotency: a check: it may run again for the same upload, so it should write nothing a second run would trip over
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="safety">
        
      </a>
      
       <code>
        safety
      </code>
    </td>
    
    <td>
      <code>
        false
      </code>
      
       | <a href="#uploadsafety">
        <code>
          UploadSafety
        </code>
      </a>
    </td>
    
    <td>
      The content check: your <code>
        ai
      </code>
      
       (<code>
        setupAi
      </code>
      
      ), whose <code>
        requireSafe
      </code>
      
       reads the upload as an image; a file that is no image is refused <code>
        unsupported_type
      </code>
      
       on <code>
        images
      </code>
      
      , and discarded. <code>
        false
      </code>
      
       keeps the upload with no content check, for files that are no images.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="about">
        
      </a>
      
       <code>
        about?
      </code>
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/api/ai#moderationsubject">
        <code>
          ModerationSubject
        </code>
      </a>
    </td>
    
    <td>
      What the content check records about the upload, for its flag: <code>
        { subject, stage }
      </code>
      
      , and <code>
        userId
      </code>
      
       or <code>
        owner
      </code>
      
       when it is not the signed-in person's. Default stage <code>
        'upload'
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="keep">
        
      </a>
      
       <code>
        keep
      </code>
    </td>
    
    <td>
      () => <code>
        Kept
      </code>
      
       | <code>
        Promise
      </code>
      
      <<code>
        Kept
      </code>
      
      >
    </td>
    
    <td>
      Keep the upload: your internal mutation that claims it with <code>
        storage.claim
      </code>
      
       and writes your row, in one transaction. What it returns, <code>
        acceptUpload
      </code>
      
       returns. <strong>
        Guarantee
      </strong>
      
       - Runs: in the action that calls <code>
        acceptUpload
      </code>
      
      , through the <code>
        ctx
      </code>
      
       your callback closed over (<code>
        ctx.runMutation
      </code>
      
       of your mutation) - Delivery: once per <code>
        acceptUpload
      </code>
      
       whose check and content check passed - Order: last, after <code>
        check
      </code>
      
       and the content check passed - When it throws: <code>
        acceptUpload
      </code>
      
       throws its error; your mutation rolled back, the claim with it, so a refusal of the file (the claim's own <code>
        invalid_input
      </code>
      
       on <code>
        file
      </code>
      
      , the type or the size, or the quota's <code>
        quota_exceeded
      </code>
      
      ) discards the upload, and any other error, an <code>
        invalid_input
      </code>
      
       on a field of yours among them, keeps it for a retry - Idempotency: your mutation's transaction: its claim and your row commit together or not at all, and a second keep of a claimed upload is refused <code>
        upload_claimed
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### SetupStorageOptions

Defined in: [src/convex/integrations/storage.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts)

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="maxsize">
        
      </a>
      
       <code>
        maxSize?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      The largest file kept, in bytes. Default 10 MB.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="accept">
        
      </a>
      
       <code>
        accept?
      </code>
    </td>
    
    <td>
      readonly <code>
        string
      </code>
      
      <span>
        
      </span>
    </td>
    
    <td>
      The types kept, as read from the file's first bytes. Default PNG, JPEG and WebP. A wildcard (<code>
        image/*
      </code>
      
      ) never admits SVG or HTML: name them to keep them.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="stripmetadata">
        
      </a>
      
       <code>
        stripMetadata?
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      Remove EXIF, XMP and GPS data from JPEG, PNG and WebP images before they are kept. Default <code>
        true
      </code>
      
      . While it is on, a wildcard such as <code>
        image/*
      </code>
      
       does not admit HEIC, HEIF, AVIF or TIFF, whose metadata can't be stripped, and naming one of them throws.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="quota">
        
      </a>
      
       <code>
        quota?
      </code>
    </td>
    
    <td>
      { <code>
        files?
      </code>
      
      : <a href="#storagequota">
        <code>
          StorageQuota
        </code>
      </a>
      
      ; <code>
        bytes?
      </code>
      
      : <a href="#storagequota">
        <code>
          StorageQuota
        </code>
      </a>
      
      ; }
    </td>
    
    <td>
      How many files and how many bytes the billing entity (else the workspace, else the account) may keep.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        quota.files?
      </code>
    </td>
    
    <td>
      <a href="#storagequota">
        <code>
          StorageQuota
        </code>
      </a>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        quota.bytes?
      </code>
    </td>
    
    <td>
      <a href="#storagequota">
        <code>
          StorageQuota
        </code>
      </a>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="billing">
        
      </a>
      
       <code>
        billing?
      </code>
    </td>
    
    <td>
      <code>
        Pick
      </code>
      
      <<a href="https://nuxt-backend.dev/docs/reference/api/billing#billing">
        <code>
          Billing
        </code>
      </a>
      
      , <code>
        "requireEntity"
      </code>
      
       | <code>
        "getQuota"
      </code>
      
       | <code>
        "plansAllowing"
      </code>
      
      >
    </td>
    
    <td>
      The app's billing, which a quota key needs.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="ratelimiter">
        
      </a>
      
       <code>
        rateLimiter?
      </code>
    </td>
    
    <td>
      { <code>
        limit
      </code>
      
      : (<code>
        ctx
      </code>
      
      , <code>
        name
      </code>
      
      , <code>
        options
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <{ <code>
        ok
      </code>
      
      : <code>
        boolean
      </code>
      
      ; <code>
        retryAfter?
      </code>
      
      : <code>
        number
      </code>
      
      ; }>; }
    </td>
    
    <td>
      The app's rate limiter, whose <code>
        upload
      </code>
      
       limit bounds upload URLs. Default: the package's own, on <code>
        components.rateLimiter
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        rateLimiter.limit
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        name
      </code>
      
      , <code>
        options
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <{ <code>
        ok
      </code>
      
      : <code>
        boolean
      </code>
      
      ; <code>
        retryAfter?
      </code>
      
      : <code>
        number
      </code>
      
      ; }>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### Storage

Defined in: [src/convex/integrations/storage.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts)

The app's storage, from [setupStorage](#setupstorage).

#### Type Parameters

<table>
<thead>
  <tr>
    <th>
      Type Parameter
    </th>
    
    <th>
      Default type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="type-parameter-dm-3">
        
      </a>
      
       <code>
        DM
      </code>
      
       <em>
        extends
      </em>
      
       <code>
        GenericDataModel
      </code>
    </td>
    
    <td>
      <code>
        GenericDataModel
      </code>
    </td>
  </tr>
</tbody>
</table>

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="store">
        
      </a>
      
       <code>
        store
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        bytes
      </code>
      
      , <code>
        owner
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<a href="#storedfile">
        <code>
          StoredFile
        </code>
      </a>
      
      >
    </td>
    
    <td>
      Check bytes a person uploaded, strip an image's metadata, and keep them with their owner record, in your mutation's transaction: a refusal stores nothing. Throws <code>
        invalid_input
      </code>
      
       on <code>
        file
      </code>
      
       (too large, a type <code>
        accept
      </code>
      
       does not list) and <code>
        quota_exceeded
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="claim">
        
      </a>
      
       <code>
        claim
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        storageId
      </code>
      
      , <code>
        owner
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <{ <code>
        size
      </code>
      
      : <code>
        number
      </code>
      
      ; }>
    </td>
    
    <td>
      Record an upload sent to an upload URL as the owner's: its stored size and the quotas now (<code>
        invalid_input
      </code>
      
       on <code>
        file
      </code>
      
      , <code>
        quota_exceeded
      </code>
      
      ), the type check and the stripping next, in the background. <code>
        getFileUrl
      </code>
      
       reads <code>
        null
      </code>
      
       until they ran; a file of a type you do not accept is deleted then.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="release">
        
      </a>
      
       <code>
        release
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        storageId
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        void
      </code>
      
      >
    </td>
    
    <td>
      Delete a file with its owner record and give its bytes back to the quota. <code>
        null
      </code>
      
      , <code>
        undefined
      </code>
      
       or an unknown id does nothing. It checks no owner: pass an id read from your own row.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="discard">
        
      </a>
      
       <code>
        discard
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        storageId
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        boolean
      </code>
      
      >
    </td>
    
    <td>
      Delete an upload at once while nobody claimed it: one a person sent to an upload URL and then dropped, or one your check refused before the claim. Never a kept file, anyone's: a claimed or stored id is left as it is, and so is an id with no file. Call it from a mutation or an action, as often as you like: it answers whether bytes went, <code>
        false
      </code>
      
       the second time. Unclaimed uploads are swept after a day anyway; this frees them now.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="bytes">
        
      </a>
      
       <code>
        bytes
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        storageId
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        Uint8Array
      </code>
      
      <<code>
        ArrayBufferLike
      </code>
      
      > | <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      A file's bytes in an action of yours, an upload not yet claimed included: what a check reads before the upload is kept (<code>
        ai.requireSafe
      </code>
      
       reads them so). <code>
        null
      </code>
      
       for an id no file has. It checks no owner: read only what your code decided the caller may send.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="acceptupload">
        
      </a>
      
       <code>
        acceptUpload
      </code>
    </td>
    
    <td>
      <<code>
        Kept
      </code>
      
      >(<code>
        ctx
      </code>
      
      , <code>
        storageId
      </code>
      
      , <code>
        options
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        Kept
      </code>
      
      >
    </td>
    
    <td>
      Accept an upload sent to an upload URL, in an action of yours: your <code>
        check
      </code>
      
      , then the content check (<code>
        safety
      </code>
      
      , your <code>
        ai
      </code>
      
      ), then your <code>
        keep
      </code>
      
      , the mutation that claims it. A refusal of the upload itself (<code>
        invalid_input
      </code>
      
       on <code>
        file
      </code>
      
       or <code>
        images
      </code>
      
      , the classifier's <code>
        content_blocked
      </code>
      
       among them, or <code>
        quota_exceeded
      </code>
      
      ) discards it at once and throws, though a file kept already stays as it is; any other failure (a provider down, another workspace's row, a caption <code>
        keep
      </code>
      
       refused) keeps it, so the same id can be sent again. Returns what <code>
        keep
      </code>
      
       returned. <strong>
        Example
      </strong>
      
       <code>
        [backend/strips.ts] export const attachPhoto = workspace.action({ args: { id: v.id('strips'), photoId: v.string() }, handler: (ctx, { id, photoId }) => storage.acceptUpload(ctx, photoId, { check: () => ctx.runQuery(internal.strips.checkPhoto, { id, photoId, workspaceId: ctx.workspace.id }), safety: ai, about: { subject: id }, keep: () => ctx.runMutation(internal.strips.keepPhoto, { id, photoId, userId: ctx.user.id, workspaceId: ctx.workspace.id }), }), })
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="fileurl">
        
      </a>
      
       <code>
        fileUrl
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        storageId
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      A file's URL once your query decided who may see it; <code>
        null
      </code>
      
       for a file that is gone or still checked.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="signedurl">
        
      </a>
      
       <code>
        signedUrl
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        storageId
      </code>
      
      , <code>
        options?
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      An expiring URL on the deployment's routes: <code>
        ttl
      </code>
      
       ms, an hour by default, seven days at most; <code>
        null
      </code>
      
       for a file that is gone or still checked. Under a day, a live query that signs one runs again every half hour, so its page holds fresh URLs (with a <code>
        ttl
      </code>
      
       of an hour or more, never an expired one), and the URL changes only once a step of half its <code>
        ttl
      </code>
      
      : it works for <code>
        ttl
      </code>
      
       at least and half as long again at most, and a run in between answers the same URL, so the browser's cache holds.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="expire">
        
      </a>
      
       <code>
        expire
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        storageId
      </code>
      
      , <code>
        at
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        boolean
      </code>
      
      >
    </td>
    
    <td>
      When a file goes: past <code>
        at
      </code>
      
       (epoch ms, or a <code>
        Date
      </code>
      
      ), the component's maintenance deletes it within the hour, with its record, and gives its bytes back to the quota; <code>
        null
      </code>
      
       keeps it again. A time already past (the epoch included) is due at the next run. Returns whether the id names a kept file. It checks no owner: pass an id read from your own row.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="shareable">
        
      </a>
      
       <code>
        shareable
      </code>
    </td>
    
    <td>
      <<code>
        T
      </code>
      
      >(<code>
        table
      </code>
      
      , <code>
        options
      </code>
      
      ) => <code>
        void
      </code>
    </td>
    
    <td>
      Mark a table's rows shareable by link: where the public page lives, who may share a row, and its preview card's image.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="resolvesharelink">
        
      </a>
      
       <code>
        resolveShareLink
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        table
      </code>
      
      , <code>
        token
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<a href="#resolvedsharelink">
        <code>
          ResolvedShareLink
        </code>
      </a>
      
       | <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      The row a token opens in a table, who shared it, and its preview card's URL; <code>
        null
      </code>
      
       for an unknown, rotated or revoked token.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="revokesharelink-1">
        
      </a>
      
       <code>
        revokeShareLink
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        table
      </code>
      
      , <code>
        id
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        void
      </code>
      
      >
    </td>
    
    <td>
      Turn a row's link off, in the mutation that deletes the row.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="api">
        
      </a>
      
       <code>
        api
      </code>
    </td>
    
    <td>
      <a href="#storageapi">
        <code>
          StorageApi
        </code>
      </a>
    </td>
    
    <td>
      The public functions <code>
        backend/storage.ts
      </code>
      
       re-exports.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### StorageComponents

Defined in: [src/convex/integrations/storage.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts)

The `backend` component as storage reads it, and the rate limiter it limits upload URLs with.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="backend">
        
      </a>
      
       <code>
        backend
      </code>
    </td>
    
    <td>
      <code>
        unknown
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="ratelimiter-1">
        
      </a>
      
       <code>
        rateLimiter?
      </code>
    </td>
    
    <td>
      <code>
        unknown
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

## Type Aliases

### ShareCtx

```ts
type ShareCtx<DM> = (GenericQueryCtx<DM> | GenericMutationCtx<DM>) & {
  user: {
     id: string;
  };
};
```

Defined in: [src/convex/integrations/storage.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts)

The context `canShare` receives: the mutation's or the query's own, and the signed-in caller.

#### Type Parameters

<table>
<thead>
  <tr>
    <th>
      Type Parameter
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="type-parameter-dm">
        
      </a>
      
       <code>
        DM
      </code>
      
       <em>
        extends
      </em>
      
       <code>
        GenericDataModel
      </code>
    </td>
  </tr>
</tbody>
</table>

#### Type Declaration

<table>
<thead>
  <tr>
    <th>
      Name
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        user
      </code>
    </td>
    
    <td>
      { <code>
        id
      </code>
      
      : <code>
        string
      </code>
      
      ; }
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        user.id
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### ShareMutationCtx

```ts
type ShareMutationCtx<DM> = GenericMutationCtx<DM> & {
  user: {
     id: string;
  };
};
```

Defined in: [src/convex/integrations/storage.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts)

The context `onEnable` receives: `enableShareLink`'s mutation, and the signed-in caller who turned the link on.

#### Type Parameters

<table>
<thead>
  <tr>
    <th>
      Type Parameter
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="type-parameter-dm-1">
        
      </a>
      
       <code>
        DM
      </code>
      
       <em>
        extends
      </em>
      
       <code>
        GenericDataModel
      </code>
    </td>
  </tr>
</tbody>
</table>

#### Type Declaration

<table>
<thead>
  <tr>
    <th>
      Name
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        user
      </code>
    </td>
    
    <td>
      { <code>
        id
      </code>
      
      : <code>
        string
      </code>
      
      ; }
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        user.id
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts" rel="nofollow">
        src/convex/integrations/storage.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### StorageQuota

```ts
type StorageQuota = number | string;
```

Defined in: [src/convex/integrations/storage.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts)

A quota: a number, or a quota key of the billing catalog.

## Variables

### DEFAULT_MAX_FILE_SIZE

```ts
const DEFAULT_MAX_FILE_SIZE: number;
```

Defined in: [src/convex/files.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/files.ts)

The largest file `setupStorage` keeps by default: 10 MB.

---

### DEFAULT_ACCEPTED_TYPES

```ts
const DEFAULT_ACCEPTED_TYPES: readonly ["image/png", "image/jpeg", "image/webp"];
```

Defined in: [src/convex/files.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/files.ts)

The types `setupStorage` keeps by default: raster images whose metadata it strips.

---

### SIGNED_URL_TTL_MS

```ts
const SIGNED_URL_TTL_MS: number;
```

Defined in: [src/convex/files.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/files.ts)

How long a signed URL works by default: an hour.

---

### SIGNED_URL_TTL_MAX_MS

```ts
const SIGNED_URL_TTL_MAX_MS: number;
```

Defined in: [src/convex/files.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/files.ts)

The longest a signed URL works: seven days.

## Functions

### sniffContentType()

```ts
function sniffContentType(input): string | null;
```

Defined in: [src/convex/files.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/files.ts)

The type a file is, read from its signature (its first bytes), or `null`
for one the package does not recognise. Never the name, never the type the
browser declared: Convex stores that one as sent.

#### Parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        input
      </code>
    </td>
    
    <td>
      <code>
        ArrayBuffer
      </code>
      
       | <code>
        Uint8Array
      </code>
      
      <<code>
        ArrayBufferLike
      </code>
      
      >
    </td>
  </tr>
</tbody>
</table>

#### Returns

`string` | `null`

---

### stripImageMetadata()

```ts
function stripImageMetadata(input, type): Uint8Array;
```

Defined in: [src/convex/files.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/files.ts)

An image's bytes without its EXIF, XMP, IPTC and GPS data, its container
rewritten and its pixels untouched, so quality is unchanged: JPEG, PNG and
WebP. A photo taken sideways keeps its orientation, alone, so it still
shows upright. Any other type comes back as it is. Throws on a file whose
container is broken, which a check reads as a type it does not accept.

#### Parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        input
      </code>
    </td>
    
    <td>
      <code>
        ArrayBuffer
      </code>
      
       | <code>
        Uint8Array
      </code>
      
      <<code>
        ArrayBufferLike
      </code>
      
      >
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        type
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
  </tr>
</tbody>
</table>

#### Returns

`Uint8Array`

---

### setupStorage()

```ts
function setupStorage<DM>(components, options?): Storage<DM>;
```

Defined in: [src/convex/integrations/storage.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/storage.ts)

Checked uploads, expiring private URLs and share links on Convex file
storage, kept in the `backend` component's storage beside one owner
record per file: the orphan sweep, an account's export and its erasure
see every file the app keeps.

A photo goes to your mutation as bytes, and `store` checks them (size,
the type read from the bytes, the quotas), strips an image's EXIF, XMP
and GPS data, and keeps it with your row in one transaction. A large file
goes to an upload URL (`generateUploadUrl`, behind `useUpload` and
`<UploadField>`), and your mutation `claim`s it: the size and the quotas
at once, the type and the stripping next.

#### Type Parameters

<table>
<thead>
  <tr>
    <th>
      Type Parameter
    </th>
    
    <th>
      Default type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="type-parameter-dm-4">
        
      </a>
      
       <code>
        DM
      </code>
      
       <em>
        extends
      </em>
      
       <code>
        GenericDataModel
      </code>
    </td>
    
    <td>
      <code>
        GenericDataModel
      </code>
    </td>
  </tr>
</tbody>
</table>

#### Parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        components
      </code>
    </td>
    
    <td>
      <a href="#storagecomponents">
        <code>
          StorageComponents
        </code>
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        options?
      </code>
    </td>
    
    <td>
      <a href="#setupstorageoptions">
        <code>
          SetupStorageOptions
        </code>
      </a>
    </td>
  </tr>
</tbody>
</table>

#### Returns

[`Storage`](#storage)<`DM`>

#### Example

```ts [backend/storage.ts]
import { setupStorage } from 'nuxt-backend/storage'
import { components } from './_generated/api'
import type { DataModel } from './_generated/dataModel'

export const storage = setupStorage<DataModel>(components, {
  maxSize: 8 * 1024 * 1024,
  accept: ['image/png', 'image/jpeg', 'image/webp'],
  quota: { files: 200, bytes: 500 * 1024 * 1024 },
})

export const { generateUploadUrl, getFileUrl } = storage.api
```


## Sitemap

See the full [sitemap](https://nuxt-backend.dev/sitemap.md) for all pages.
