Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

483
Vistas
Node Fetch blobFromSync and blobFrom TypeError [ERR_INVALID_URL]: Invalid URL

I am trying to read a file that is local to my computer into a blob using the node-fetch library, but each time I do, I get this Invalid Url Error. My code is the following:

const express = require('express');
const cors = require('cors');
const bodyParser = require("body-parser");


const fetch = (...args) =>
  import('node-fetch').then(({ default: fetch }) => fetch(...args));

const blobFromSync = (...args) =>
  import('node-fetch').then(({ blobFromSync }) => fetch(...args));

  const blobFrom = (...args) =>
  import('node-fetch').then(({ blobFrom }) => fetch(...args));

  const fileFrom = (...args) =>
  import('node-fetch').then(({ fileFrom }) => fetch(...args));



const app = express();
const port = 3000;

//Here we are configuring express to use body-parser as middle-ware.
app.use(cors())
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());

app.use(function (req, res, next) {
    res.header("Access-Control-Allow-Origin", "*")
    res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept")
    next()
});


app.get('/recorded', async (req, res) => {

    try {
   
        let file_location = './path/to/video.mp4';

        const file = fileFrom(file_location);

        const chunkSize = 40000

        for (let start = 0; start < file.size; start += chunkSize) {
            const chunk = file.slice(start, start + chunkSize + 1)
            //Will eventuay doa fetch
            //await fetch(url, { method: 'post', body: chunk, headers: headers, }).then(res => res.text())
        }

        res.status(200);
        res.send().end();
    } catch (e) {
        console.log(e);
    }
});


app.listen(port, () => {
    console.log(`Example app listening on port ${port}`)
});

The error is the following (its also uncatchable):

TypeError [ERR_INVALID_URL]: Invalid URL
    at new NodeError (node:internal/errors:377:5)
    at URL.onParseError (node:internal/url:563:9)
    at new URL (node:internal/url:643:5)
    at new Request (file:///Users/xxxxxx/Development/terminal-backend/node_modules/node-fetch/src/request.js:55:16)
    at file:///Users/xxxx/Development/terminal-backend/node_modules/node-fetch/src/index.js:51:19
    at new Promise (<anonymous>)
    at fetch (file:///Users/xxxx/Development/terminal-backend/node_modules/node-fetch/src/index.js:49:9)
    at /Users/xxxxx/Development/terminal-backend/src/server.js:11:53 {
  input: './path/to/video.mp4',
  code: 'ERR_INVALID_URL'
}

blobFromSync and blobFrom also throw the same error. If this is a local file, why am I get invalid url?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda