rusackas commented on issue #36385:
URL: https://github.com/apache/superset/issues/36385#issuecomment-3604345256

   It does seem that if we're using fetch for this API call, it'd be possible 
to _start_ receiving the stream of data, but you could check the size and abort 
if it's too large before _processing_ the data and receiving the rest of the 
response. Something like 
   
   ```
   const controller = new AbortController();
   const response = await fetch(url, { signal: controller.signal });
   
   const size = Number(response.headers.get("content-length"));
   
   if (size > MAX_SIZE) {
     controller.abort(); // stops downloading the rest
     throw new Error("File too large");
   }
   
   // Safe to proceed — now read/parse body
   const json = await response.json();
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to