MCPcopy
hub / github.com/transloadit/uppy / createTransloaditUppy

Function createTransloaditUppy

examples/reactrouter/app/routes/_index.tsx:40–73  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

38}
39
40function createTransloaditUppy() {
41 const uppy = new Uppy({
42 restrictions: {
43 maxFileSize: 100 * 1024 * 1024, // 100MB
44 maxNumberOfFiles: 10,
45 },
46 })
47
48 uppy.use(Transloadit, {
49 async assemblyOptions() {
50 // You can send meta data along for use in your template.
51 // https://transloadit.com/docs/topics/assembly-instructions/#form-fields-in-instructions
52 const { meta } = uppy.getState()
53 const body = JSON.stringify({
54 customValue: meta.customValue || 'react-router-uppy-example',
55 })
56 const res = await fetch('/api/transloadit-params', {
57 method: 'POST',
58 headers: { 'Content-Type': 'application/json' },
59 body,
60 })
61 if (!res.ok) {
62 const errorData = await res.json().catch(() => ({}))
63 if (errorData.details) {
64 throw new Error(errorData.details)
65 }
66 throw new Error(`Failed to get Transloadit params: ${res.statusText}`)
67 }
68 return res.json()
69 },
70 })
71
72 return uppy
73}
74
75export default function Index() {
76 const [tusUppy] = useState(createTusUppy)

Callers

nothing calls this directly

Calls 1

useMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…