Commit ab94b39d authored by Guillaume Perréal's avatar Guillaume Perréal
Browse files

Utilise si possible stream_copy_to_stream pour enregistrer les fichiers à l'upload.

parent 3c24e692
No related merge requests found
Showing with 13 additions and 1 deletion
+13 -1
......@@ -123,7 +123,19 @@ class UploadController extends Controller
$stream = $file->open('wb');
}
$stream->write($request->getContent());
// Demande un filehandle plutôt que charger le contenu en mémoire
$input = $request->getContent(true);
if(false !== $fileHandler = $stream->cast(STREAM_CAST_AS_STREAM)) {
// Utilise stream_copy_to_stream si le Gaufrette\Stream peut nous retourner un filehandle
stream_copy_to_stream($input, $fileHandler);
} else {
// Sinon fait une copie par blocs (moins performant)
while(!feof($input)) {
$stream->write(fread($input, 8192));
}
}
fclose($input);
$stream->close();
if(!$final) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment