Skip to content

Commit 070f29d

Browse files
committed
fix http stream
1 parent 3d8045d commit 070f29d

1 file changed

Lines changed: 2 additions & 11 deletions

File tree

src/components/httpRoutes/persistentStorage.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,6 @@ import {
1616

1717
export const persistentStorageRoutes = express.Router()
1818

19-
function readRawBody(req: any): Promise<Buffer> {
20-
return new Promise((resolve, reject) => {
21-
const chunks: Buffer[] = []
22-
req.on('data', (chunk: any) => chunks.push(Buffer.from(chunk)))
23-
req.on('end', () => resolve(Buffer.concat(chunks)))
24-
req.on('error', reject)
25-
})
26-
}
27-
2819
// Create bucket
2920
persistentStorageRoutes.post(
3021
`${SERVICES_API_BASE_PATH}/persistentStorage/buckets`,
@@ -144,7 +135,6 @@ persistentStorageRoutes.post(
144135
`${SERVICES_API_BASE_PATH}/persistentStorage/buckets/:bucketId/files/:fileName`,
145136
async (req, res) => {
146137
try {
147-
const raw = await readRawBody(req)
148138
const response = await new PersistentStorageUploadFileHandler(req.oceanNode).handle(
149139
{
150140
command: PROTOCOL_COMMANDS.PERSISTENT_STORAGE_UPLOAD_FILE,
@@ -153,7 +143,8 @@ persistentStorageRoutes.post(
153143
nonce: req.query.nonce as string,
154144
bucketId: req.params.bucketId,
155145
fileName: req.params.fileName,
156-
stream: Readable.from(raw),
146+
// Stream request body directly (supports chunked uploads, avoids buffering).
147+
stream: req,
157148
authorization: req.headers?.authorization,
158149
caller: req.caller
159150
} as any

0 commit comments

Comments
 (0)