-
Notifications
You must be signed in to change notification settings - Fork 498
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
Add ability to pass in a file pointer #34
Comments
There's no native way to pass files in, you'll need to pass a string in via the |
I'll just add (while writing code that needs to post 20 meg CSV files to a remote server), that it would be nice if the Otherwise, you need to load the whole file into memory in order to pass it as the request. |
Reopened, as that is a good point. Whether that's technically possible in the transports, I'm not sure. In terms of API design, I think ideally:
I'm not sure, but I feel like we should be able to handle cases 2 and 3 in the same way. It doesn't seem like |
Based on PHP bug #36289, it looks like SplFileObject is unsuitable for this. I'd prefer to write a file-like interface and wrap file resources suitably instead. |
Hrm, I never noticed that SplFileObject wasn't useful for binary files .. good to know. As for the actual upload, would it not be something like this pseudocoe (at least as far as the cURL transport is concerned): if ( get_resource_type($data) == 'stream' ) {
curl_setopt($ch, CURLOPT_INFILE, $data);
// kludge to get size of file when only given the resource
fseek ( $data, 0, SEEK_END );
$size = ftell($data);
curl_setopt($ch, CURLOPT_INFILESIZE, $size );
rewind($data);
} |
Anything new about this? I need to upload a file via post as well. |
I'm also interested in this. |
Any progress here? |
Not yet available in the last build. I'm interested in it too. |
PHP 5.5 now has CurlFile support: https://secure.php.net/manual/en/class.curlfile.php |
Anyone have a fork making this work? |
I just shifted to guzzle, which is doing really well in terms of development. |
Yeah, but the main selling point of this library was 5.2 compatibility (not my decision!) which Guzzle doesn't offer. |
Related #289 |
How to post file data / upload file using requests? I can;t find any documentation on this.
Like in
HttpRequest
, we have a method calledaddPostFile()
The text was updated successfully, but these errors were encountered: