http `upload` endpoint to pack many files into a car?
tomjohnhall opened this issue · 1 comments
I've been working on an integration which uses the upload endpoint, mostly so that I can work with streams rather than buffer files in memory - they generally aren't large files but it would be more efficient to just pipe the data straight to the endpoint. I was hoping to be able to upload multiple files and get back a car
just like the putFiles
method of the js SDK. Digging into the code I noticed this comment:
packages/api/src/upload.js
// TODO: do we want to wrap file uploads like we do car uploads from the client?
// this path used to send the files to cluster and we didn't wrap, so we dont here for consistency with the old ways.
const { car } = await packToBlob({
input,
maxChunkSize: MAX_CHUNK_SIZE,
maxChildrenPerNode: MAX_CHILDREN_PER_NODE,
wrapWithDirectory: false
})
How feasible would it be to have a version of the upload endpoint which does take a number of files and return a car
which contains them? At the moment I'm getting back a carCid
which doesn't resolve on the gateway, and a cid
which returns the first file, and my account shows that single file uploaded.
That said, maybe my request is formatted slightly wrong for multiple files - seems fine but perhaps I'm missing something!
Thanks for any help!
The put
method of the client takes a files
parameter which is an array of Filelike
. Filelike
are just objects with a stream()
function that returns a stream.
With this you should be able to upload multiple files, and stream them.