Update the network download method to POST and return value

This commit is contained in:
Arnaud 2024-10-25 10:37:34 +02:00
parent b059830cec
commit 342cfc469a
No known key found for this signature in database
GPG Key ID: 69D6CE281FCAE663

View File

@ -130,11 +130,11 @@ export class CodexData {
* Download a file from the network in a streaming manner.
* If the file is not available locally, it will be retrieved from other nodes in the network if able.
*/
async networkDownload(cid: string) {
async networkDownload(cid: string): Promise<SafeValue<ReadableStream<Uint8Array> | null>> {
const url = this.url + Api.config.prefix + `/data/${cid}/network`;
const res = await Fetch.safe(url, {
method: "GET",
method: "POST",
headers: {
"content-type": "application/octet-stream",
},
@ -144,7 +144,7 @@ export class CodexData {
return res;
}
return res.data.body;
return { error: false, data: res.data.body };
}
/**