Skip to content

Commit

Permalink
Merge pull request #341 from kodadot/feat/directory
Browse files Browse the repository at this point in the history
⚡ fix uploading directories
  • Loading branch information
vikiival authored Oct 16, 2024
2 parents caa00ef + 3ec3b80 commit 67da514
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions services/ipos/src/routes/pinning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ app.post('/pinFile', vValidator('form', pinFileRequestSchema), async (c) => {
import: 'car',
},
})

const promises: Promise<R2Object | null>[] = []
for (const { file } of files) {
const path = `${cid}/${file.name}`
promises.push(c.env.BUCKET.put(keyOf(path), file))
}

c.executionCtx.waitUntil(Promise.allSettled(promises))
} else {
const { content, file: f } = files[0]
cid = (await hashOf(content)).toV0().toString()
Expand All @@ -103,9 +111,9 @@ app.post('/pinFile', vValidator('form', pinFileRequestSchema), async (c) => {
Key: cid,
ContentType: f.type,
})
}

c.executionCtx.waitUntil(c.env.BUCKET.put(keyOf(cid), file))
c.executionCtx.waitUntil(c.env.BUCKET.put(keyOf(cid), file))
}

return c.json(
getPinResponse({
Expand Down

0 comments on commit 67da514

Please sign in to comment.