Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stream and BinaryFileResponse generates error in Chrome #103

Open
Schyzophrenic opened this issue Nov 29, 2014 · 0 comments
Open

Stream and BinaryFileResponse generates error in Chrome #103

Schyzophrenic opened this issue Nov 29, 2014 · 0 comments
Assignees

Comments

@Schyzophrenic
Copy link

Hello,

I run into a pretty odd issue.
I have setup a local adapter, which works fine. I write into it without any issue.

But things get strange when I try to deliver the file through the BinaryFileResponse as Chrome complains about : ERR_CONTENT_LENGTH_MISMATCH

Here is how I ask for the file delivery (full details below);

$response = new BinaryFileResponse('gaufrette://stream/'.$track->getFilename(), 200, $headers, false);

The odd thing is that it works if I call the file directly with

$response = new BinaryFileResponse($streamDir.'/'.$track->getFilename(), 200, $headers, false);

I have checked the Content-length header in the BinaryFileResponse and it seems ok...

I am bit lost here and would appreciate any help on this.

Here is the gaufrette config:

knp_gaufrette:
    adapters:
        stream:
            local:
                directory: "%stream_directory%"
                create: true
    filesystems:
        stream:
            adapter: stream
    stream_wrapper: ~

And here is the code used by my controller to deliver the file:

$streamFileSystem = $this->get('knp_gaufrette.filesystem_map')->get('stream');
$map = StreamWrapper::getFilesystemMap();
$map->set('stream', $streamFileSystem);
StreamWrapper::register();

// We prepare the headers of the response
$headers = array(
    'Content-Type'      => 'audio/mpeg',
    'Pragma'            => 'no-cache',
    'Transfer-Encoding' => 'none',
    'Connection'        => 'close',
    'Accept-Ranges'     => 'none',
);

$response = new BinaryFileResponse('gaufrette://stream/'.$track->getFilename(), 200, $headers, false);

return $response;

Note: I call the url directly, there is no HTML involved in this process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants