• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / storage / 27131902167

08 Jun 2026 10:35AM UTC coverage: 42.746% (-33.7%) from 76.41%
27131902167

Pull #1139

github

web-flow
Merge 4f7c37c69 into 74a0f6472
Pull Request #1139: feat: use @smithy/undici-http-handler for S3 client

2498 of 6435 branches covered (38.82%)

Branch coverage included in aggregate %.

10 of 24 new or added lines in 5 files covered. (41.67%)

3801 existing lines in 169 files now uncovered.

4895 of 10860 relevant lines covered (45.07%)

34.32 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

18.75
/src/http/routes/object/uploadSignedObject.ts
1
import fastifyMultipart from '@fastify/multipart'
2
import { SIGNED_URL_SCOPE_UPLOAD } from '@internal/auth'
3
import { FastifyInstance } from 'fastify'
4
import { FromSchema } from 'json-schema-to-ts'
5
import { ROUTE_OPERATIONS } from '../operations'
6

7
const uploadSignedObjectParamsSchema = {
2✔
8
  type: 'object',
9
  properties: {
10
    bucketName: { type: 'string', examples: ['avatars'] },
11
    '*': { type: 'string', examples: ['folder/cat.png'] },
12
  },
13
  required: ['bucketName', '*'],
14
} as const
15

16
const uploadSignedObjectQSSchema = {
2✔
17
  type: 'object',
18
  properties: {
19
    token: {
20
      type: 'string',
21
      examples: [
22
        'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1cmwiOiJidWNrZXQyL3B1YmxpYy9zYWRjYXQtdXBsb2FkMjMucG5nIiwiaWF0IjoxNjE3NzI2MjczLCJleHAiOjE2MTc3MjcyNzN9.uBQcXzuvXxfw-9WgzWMBfE_nR3VOgpvfZe032sfLSSk',
23
      ],
24
    },
25
  },
26
  required: ['token'],
27
} as const
28

29
const successResponseSchema = {
2✔
30
  type: 'object',
31
  properties: {
32
    Key: { type: 'string', examples: ['avatars/folder/cat.png'] },
33
  },
34
  required: ['Key'],
35
}
36

37
interface UploadSignedObjectRequestInterface {
38
  Params: FromSchema<typeof uploadSignedObjectParamsSchema>
39
  Querystring: FromSchema<typeof uploadSignedObjectQSSchema>
40
  Headers: {
41
    range?: string
42
  }
43
}
44

45
export default async function routes(fastify: FastifyInstance) {
UNCOV
46
  const summary = 'Uploads an object via a presigned URL'
×
47

UNCOV
48
  fastify.register(fastifyMultipart, {
×
49
    limits: {
50
      fields: 10,
51
      files: 1,
52
    },
53
    throwFileSizeLimit: false,
54
  })
55

UNCOV
56
  fastify.addContentTypeParser(
×
57
    ['application/json', 'text/plain'],
58
    function (request, payload, done) {
59
      done(null)
×
60
    }
61
  )
62

UNCOV
63
  fastify.put<UploadSignedObjectRequestInterface>(
×
64
    '/upload/sign/:bucketName/*',
65
    {
66
      // @todo add success response schema here
67
      schema: {
68
        params: uploadSignedObjectParamsSchema,
69
        querystring: uploadSignedObjectQSSchema,
70
        summary,
71
        response: {
72
          200: { description: 'Successful response', ...successResponseSchema },
73
          '4xx': { $ref: 'errorSchema#', description: 'Error response' },
74
        },
75
        tags: ['object'],
76
      },
77
      config: {
78
        operation: { type: ROUTE_OPERATIONS.UPLOAD_SIGN_OBJECT },
79
      },
80
    },
81
    async (request, response) => {
82
      // Validate sender
UNCOV
83
      const { token } = request.query
×
UNCOV
84
      const { bucketName } = request.params
×
UNCOV
85
      const objectName = request.params['*']
×
86

UNCOV
87
      const { owner, upsert } = await request.storage
×
88
        .from(bucketName)
89
        .verifyObjectSignature(token, objectName, SIGNED_URL_SCOPE_UPLOAD)
90

UNCOV
91
      const { objectMetadata, path } = await request.storage
×
92
        .asSuperUser()
93
        .from(bucketName)
94
        .uploadFromRequest(request, {
95
          owner,
96
          objectName,
97
          isUpsert: upsert,
98
          signal: request.signals.body.signal,
99
        })
100

UNCOV
101
      return response.status(objectMetadata?.httpStatusCode ?? 200).send({
×
102
        Key: path,
103
      })
104
    }
105
  )
106
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc