MCPcopy Create free account
hub / github.com/parse-community/parse-server / read

Function read

src/Routers/FilesRouter.js:24–60  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

22
23 const output = new Readable({
24 read() {
25 if (!started) {
26 started = true;
27
28 onData = (chunk) => {
29 totalBytes += chunk.length;
30 if (totalBytes > maxBytes) {
31 output.destroy(
32 new Parse.Error(
33 Parse.Error.FILE_SAVE_ERROR,
34 `File size exceeds maximum allowed: ${maxBytes} bytes.`
35 )
36 );
37 return;
38 }
39 if (!output.push(chunk)) {
40 source.pause();
41 }
42 };
43
44 onEnd = () => {
45 sourceEnded = true;
46 output.push(null);
47 };
48
49 onError = (err) => output.destroy(err);
50
51 source.on('data', onData);
52 source.on('end', onEnd);
53 source.on('error', onError);
54 }
55
56 // Resume source in case it was paused due to backpressure
57 if (!sourceEnded) {
58 source.resume();
59 }
60 },
61 destroy(err, callback) {
62 if (onData) {
63 source.removeListener('data', onData);

Callers

nothing calls this directly

Calls 1

destroyMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…