diff --git a/services/ipos/src/routes/pinning.ts b/services/ipos/src/routes/pinning.ts index 0e786b1..3c6c263 100644 --- a/services/ipos/src/routes/pinning.ts +++ b/services/ipos/src/routes/pinning.ts @@ -90,6 +90,14 @@ app.post('/pinFile', vValidator('form', pinFileRequestSchema), async (c) => { import: 'car', }, }) + + const promises: Promise[] = [] + 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() @@ -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({