Commit 07d3abb 1 parent 9885347 commit 07d3abb Copy full SHA for 07d3abb
File tree 3 files changed +3
-10
lines changed
3 files changed +3
-10
lines changed Original file line number Diff line number Diff line change 1
- import { stringify } from 'superjson' ;
2
-
3
1
import { env } from '@/env.mjs' ;
4
2
import { trpc } from '@/lib/trpc/client' ;
5
3
import { RouterInputs } from '@/lib/trpc/types' ;
@@ -14,8 +12,7 @@ export const uploadFile = async (params: {
14
12
try {
15
13
const presignedUrlOutput =
16
14
await params . trpcClient . files . uploadPresignedUrl . mutate ( {
17
- // Metadata is a Record<string, string> but should be serialized for trpc-openapi
18
- metadata : params . metadata ? stringify ( params . metadata ) : undefined ,
15
+ metadata : params . metadata ,
19
16
collection : params . collection ,
20
17
type : params . file . type ,
21
18
size : params . file . size ,
Original file line number Diff line number Diff line change @@ -42,10 +42,7 @@ export type UploadSignedUrlInput = z.infer<
42
42
> ;
43
43
export const zUploadSignedUrlInput = ( ) =>
44
44
z . object ( {
45
- /**
46
- * Must be a string as trpc-openapi requires that attributes must be serialized
47
- */
48
- metadata : z . string ( ) . optional ( ) ,
45
+ metadata : z . record ( z . string ( ) , z . string ( ) ) . optional ( ) ,
49
46
name : z . string ( ) ,
50
47
type : z . string ( ) ,
51
48
size : z . number ( ) ,
Original file line number Diff line number Diff line change 1
1
import { TRPCError } from '@trpc/server' ;
2
- import { parse } from 'superjson' ;
3
2
4
3
import { FILES_COLLECTIONS_CONFIG } from '@/lib/s3/config' ;
5
4
import {
@@ -44,7 +43,7 @@ export const filesRouter = createTRPCRouter({
44
43
return await getS3UploadSignedUrl ( {
45
44
key : config . getKey ( { user : ctx . user } ) ,
46
45
metadata : input . metadata
47
- ? { name : input . name , ...parse ( input . metadata ) }
46
+ ? { name : input . name , ...input . metadata }
48
47
: undefined ,
49
48
} ) ;
50
49
} ) ,
You can’t perform that action at this time.
0 commit comments