Skip to content

Commit 67da514

Browse files
authored
Merge pull request #341 from kodadot/feat/directory
⚡ fix uploading directories
2 parents caa00ef + 3ec3b80 commit 67da514

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

services/ipos/src/routes/pinning.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,14 @@ app.post('/pinFile', vValidator('form', pinFileRequestSchema), async (c) => {
9090
import: 'car',
9191
},
9292
})
93+
94+
const promises: Promise<R2Object | null>[] = []
95+
for (const { file } of files) {
96+
const path = `${cid}/${file.name}`
97+
promises.push(c.env.BUCKET.put(keyOf(path), file))
98+
}
99+
100+
c.executionCtx.waitUntil(Promise.allSettled(promises))
93101
} else {
94102
const { content, file: f } = files[0]
95103
cid = (await hashOf(content)).toV0().toString()
@@ -103,9 +111,9 @@ app.post('/pinFile', vValidator('form', pinFileRequestSchema), async (c) => {
103111
Key: cid,
104112
ContentType: f.type,
105113
})
106-
}
107114

108-
c.executionCtx.waitUntil(c.env.BUCKET.put(keyOf(cid), file))
115+
c.executionCtx.waitUntil(c.env.BUCKET.put(keyOf(cid), file))
116+
}
109117

110118
return c.json(
111119
getPinResponse({

0 commit comments

Comments
 (0)