1
Download Example in documentation seems not to work anymore
complete
gwildu
I tried out your streamToString method documented here: https://docs.digitalocean.com/products/spaces/reference/s3-sdk-examples/#download-a-file-from-a-space but it seems not to work anymore.
I get a typeError: stream.on is not a function.
With this code it seems to work (typescript but should also work in js):
const streamToString = async (stream: ReadableStream) => {
const reader = stream.getReader();
const chunks = [];
let stop = false;
while (!stop) {
const { done, value } = await reader.read();
if (value) {
chunks.push(value);
}
if (done) {
stop = true;
}
}
return Buffer.concat(chunks).toString("utf-8");
};
John Mulhausen
complete
Closing due to non-responsiveness
G
Gabriel Marimón
Hi, thank you for your feedback! Unfortunately, I couldn't replicate your error – I retried our instructions and our documented method seems perfectly functional with the latest versions of all relevant software. On my machine, the method you linked results in a syntax error: missing ) after argument list on the first line. Could this possibly have to do with your S3 client configuration or typescript setup?