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

122
Vistas
Laravel with Resumable.js failed uploading large file and slow server response

From the start:

I'm using XAMPP as a server stack for testing project which is something like google drive. What I wanted to achieve is that User can upload any size and type of file. I'm using for it Resumable.js which divides file into the chunks(1024KB) and sends it onto the server (Apache). I assume this will exclude changes in php.ini file (upload_max_filesize, post_max_size) ?

For testing I've used 9,6GB Linux image. There were two problems:

  1. File was uploading 4,5 hours (TTFB increases every minute from 300ms to 10s close to the end of upload). What fix is possible?
  2. While upload "finishes" it sends Error 500 and it not merge the files together. Is it possible to change something in Apache config? Probably response error?

When I've tested which are less than ~1GB it works. That was stress test. XAMPP is the blank install, nothing changed in any config file.

JS function handling uploading:

let resumable = new Resumable({
    target: '{{ route('upload.large') }}',
    query:{_token:'{{ csrf_token() }}'} ,// CSRF token
    fileType: [],
    headers: {
        'Accept' : 'application/json'
    },
    testChunks: false,
    throttleProgressCallbacks: 1,
});

Upload function in Controller:

public function upload(Request $request)
{
    $receiver = new FileReceiver('file', $request, HandlerFactory::classFromRequest($request));

    if (!$receiver->isUploaded()) {
        // file not uploaded
    }

    $fileReceived = $receiver->receive(); // receive file
    if ($fileReceived->isFinished()) { // file uploading is complete / all chunks are uploaded
        $file = $fileReceived->getFile(); // get file
        $extension = $file->getClientOriginalExtension();
        $fileName = $file->getClientOriginalName(); //file name without extenstion

        $disk = Storage::disk(config('filesystems.default'));
        $path = $disk->putFileAs('videos', $file, $fileName);

        // delete chunked file
        unlink($file->getPathname());
        return [
            'path' => asset('storage/' . $path),
            'filename' => $fileName
        ];
    }

    // otherwise return percentage informatoin
    $handler = $fileReceived->handler();
    return [
        'done' => $handler->getPercentageDone(),
        'status' => true
    ];
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I'm getting close to solving this problem (which I'm having myself). It seems that the failure occurs when the chunks are being merged together to recreate the original file. I'm getting a "Failed to open input stream" once the file size hits 4.4GB. I'm suspecting the file append is limited or the memory isn't getting released. Hopefully this helps narrow it down.

about 4 years ago · Juan Pablo Isaza Denunciar
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