I'm having issues uploading large files using Guzzle ( 5.2.0 )
I added the progress event listener and got this output:
Downloaded 0 of 0 Uploaded 966656 of 1467594
Downloaded 0 of 0 Uploaded 983040 of 1467594
Downloaded 0 of 0 Uploaded 999424 of 1467594
Downloaded 0 of 0 Uploaded 1015808 of 1467594
Downloaded 0 of 0 Uploaded 1032192 of 1467594
Downloaded 0 of 0 Uploaded 1048576 of 1467594
Downloaded 0 of 0 Uploaded 1064960 of 1467594
Downloaded 0 of 0 Uploaded 1081344 of 1467594
Downloaded 0 of 0 Uploaded 1097728 of 1467594
Downloaded 0 of 0 Uploaded 1114112 of 1467594
Downloaded 0 of 0 Uploaded 1130496 of 1467594
Downloaded 0 of 0 Uploaded 1146880 of 1467594
Downloaded 0 of 0 Uploaded 1146880 of 1467594
Downloaded 0 of 0 Uploaded 1146880 of 1467594
Downloaded 0 of 0 Uploaded 1146880 of 1467594
Downloaded 0 of 0 Uploaded 1146880 of 1467594
Downloaded 0 of 0 Uploaded 1146880 of 1467594
Downloaded 0 of 0 Uploaded 1146880 of 1467594
Downloaded 0 of 0 Uploaded 1146880 of 1467594
Downloaded 0 of 0 Uploaded 1146880 of 1467594
Downloaded 0 of 0 Uploaded 1146880 of 1467594
Downloaded 0 of 0 Uploaded 1146880 of 1467594
Downloaded 0 of 0 Uploaded 1146880 of 1467594
Downloaded 0 of 0 Uploaded 1146880 of 1467594
It appears to get stuck at 1146880 bytes every time, hangs and then hits the curl timeout.
Here's how I'm formatting the guzzle request:
$client = new \GuzzleHttp\Client();
$endpoint = 'http://myendpoint.com'
$file = new splfileobject( '/path/to/file' )
$options = [
"body" => [
"file" => fopen( $file->getRealPath(), 'r' )
]
]
$client->post( $endpoint, $options );
When I switch to using raw curl, I'm able to upload the image using the '@filename' syntax.
Any ideas? thank you !
Have you tried this?
"file" => "@" . $file->getRealPath()
I found that this guy had similar problems - http://alex-panshin.me/blog/file-upload-with-guzzle/
I think he was receiving a 413 (Request Too Large) - What HTTP error response (if any) are you getting?
See this for more information https://craftcms.stackexchange.com/a/2330
If all else fails try and capture the headers set when using curl and those set when using Guzzle and figure out if there's a difference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With