MCPcopy Create free account
hub / github.com/campsite/campsite / transformFile

Function transformFile

apps/web/utils/transformFile.ts:63–92  ·  view source on GitHub ↗
(file: File, isOnDisk = false)

Source from the content-addressed store, hash-verified

61}
62
63export async function transformFile(file: File, isOnDisk = false): Promise<TransformedFile> {
64 const isOrigami = file.type === '' && file.name.endsWith('.origami')
65 const isPrinciple = file.type === '' && file.name.endsWith('.prd')
66 const isStitch = file.type === '' && file.name.endsWith('.stitch')
67 const isLottie = await fileIsLottie(file)
68 let type = file.type
69
70 if (isOrigami) type = 'origami'
71 if (isPrinciple) type = 'principle'
72 if (isStitch) type = 'stitch'
73 if (isLottie) type = 'lottie'
74
75 const raw = new File([file], file.name, { type })
76
77 const metadata = await generateFileMetadata(file, isOnDisk)
78
79 return {
80 ...metadata,
81 optimistic_src: metadata.url,
82 id: uuid(),
83 raw,
84 type,
85 relative_url: null,
86 key: null,
87 preview_file_path: null,
88 error: null,
89 name: file.name,
90 size: file.size
91 }
92}

Callers 4

onDropFunction · 0.90
CustomReactionUploaderFunction · 0.90
FeedbackDialogFunction · 0.90
CoverPhotoUploaderFunction · 0.90

Calls 2

fileIsLottieFunction · 0.85
generateFileMetadataFunction · 0.85

Tested by

no test coverage detected