★ wanayoo — archive 1999 https://github.com/cloudconvert/cloudconvert-php/pull/55Nouvelle recherche | Portail wanayoo
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

Fix download using too much memory #55

Merged
merged 1 commit into from Mar 13, 2019

Conversation

@adrienbrault
Copy link
Contributor

@adrienbrault adrienbrault commented Mar 13, 2019

No description provided.

@josiasmontag
Copy link
Contributor

@josiasmontag josiasmontag commented Mar 13, 2019

Can you explain why your implementation uses less memory than the current one? It currently uses streams as well?

@adrienbrault
Copy link
Contributor Author

@adrienbrault adrienbrault commented Mar 13, 2019

$local->write($download);

Psr\Http\Message\StreamInterface::write expects a string. However $download is a StreamInterface, so Psr\Http\Message\StreamInterface::__toString is implicitly called ( https://github.com/guzzle/psr7/blob/31ea59d632d3ac145300fffb2873a195172c0814/src/Stream.php#L249 )

@josiasmontag
Copy link
Contributor

@josiasmontag josiasmontag commented Mar 13, 2019

Thanks!

@josiasmontag josiasmontag merged commit f417a75 into cloudconvert:master Mar 13, 2019
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@m4tthumphrey
Copy link
Contributor

@m4tthumphrey m4tthumphrey commented Apr 10, 2019

This caused an issue in production for me when I just updated to 2.2.1:

stream_copy_to_stream() expects parameter 2 to be resource

I was passing an instance of Psr\Http\Message\StreamInterface to the Cloudconvert\Process::downloadStream() method. This worked fine before because L157 handled this. The change has removed this functionality so that the $stream argument is passed directly to stream_copy_to_stream() which only accepts a resource.

I understand that the method expects a resource and not StreamInterface however it worked correctly before so this comment is more of a warning to others incase they are doing the same.

I have not worked enough with Psr7 streams to come up with a decent solution yet so I have just rolled back to 2.2.0 for now but will revisit this to look at a proper solution when I have time.

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

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.