Upload file : Cannot create a string longer than 0x1fffffe8 characters

Hi
We’ trying to upload a 430 Meg file and get the error : > Cannot create a string longer than 0x1fffffe8 characters.

Looks to be in the core- Any idea on how to solve or work around this ?

Would you mind to share the code that you are using to upload the file?

I experienced this error while fetching a file. To optimize the efficiency of the proxy server, I implemented buffer-based data streaming with chunking in my code using Node.js. Here’s an example of how you can do it:

When the error occurred, I used to send response data like this:
// Send the response data
res.status(response.status).send(response.data);

I also set the response type as Blob:
const response = await axios.get(url, { responseType: ‘blob’ });

After making the correction, I send the response like this:
// Send the response as a stream
response.data.pipe(res);

And I set the response type as Stream:
const response = await axios.get(url, { responseType: 'stream' });

This approach should help improve the speed and memory usage when transferring large files or streams of data.

server.js

const axios = require('axios');
const express = require('express');
const app = express();

app.get('/proxy', async (req, res) => {
  const name = req.query.topic;
  const url = req.query.url;

  try {
    const response = await axios.get(url, { responseType: 'stream' });

    // Set the Content-Type header to 'video/mp4'
    res.setHeader('Content-Type', 'video/mp4');

    // Set the Content-Disposition header to suggest a filename
    res.setHeader('Content-Disposition', `inline; filename="${name}.mp4"`);

    // Forward the response headers from the remote server
    for (const [key, value] of Object.entries(response.headers)) {
      res.setHeader(key, value);
    }

    // Stream the response data in chunks
    response.data.pipe(res);
  } catch (error) {
    console.error('Proxy error:', error.message);
    res.status(500).send('Proxy error');
  }
});

const port = process.env.PORT || 3000;
app.listen(port, () => {
  console.log(`Server is running on port ${port}`);
});