Re: PR 1217: Add support for upload files from buffer string in curl extenion
| From: | Alexander Moskalev | Date: | Thu, 23 Apr 2015 11:26:01 +0000 |
| Subject: | Re: PR 1217: Add support for upload files from buffer string in curl extenion | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-85919@lists.php.net to get a copy of this message | ||
Because currently CURLFile have this constructor:
public __construct <http://php.net/manual/en/curlfile.construct.php>
(
string $filename [, string $mimetype [, string $postname ]] )
And we cannot replace this arguments to avoid BC break.
2015-04-23 11:59 GMT+03:00 Michael Wallner <mike@php.net>:
>
> On 22 Apr 2015 10:27, "Alexander Moskalev" <irker@irker.net> wrote:
> >
> > Thanks to all for feedback!
> >
> > Let's try to integrate new feature to old class.
> > We have constructor in CURLFile with one required parameter: $filename .
> > To avoid BC break we cannot replace this parameter. So I suggest to do
> it
> > optional and add setBuffer() method.
> >
> > So we can create CURLFile with empty parameters in constructor and fill
> it
> > with setters.
> > Have two more questions:
> > 1) If we not fill all options or fille not compatible options, when we
> must
> > throw error? ? And what level of this error? (Sorry, I'm just php coder
> and
> > know about C language and php source so little)
> > For file from disk(or other source) required $filename. For file from
> > buffer required $buffer and $postname.
> > 2) Curently CURLFile cannot be unserialized, because it contains
> $filename
> > (see source code). How it compatible with our dicussion?
> >
>
> Why not a ctor as in:
>
> function __construct ($filename, $buffer = null) {
> if (isset ($ buffer)) {
> // use $ buffer
> } else {
> // use file contents
> }
> }
>
> The file name parameter can be of use anyway for posted file contents from
> buffer.
>
> Cheers,
> Mike
>
--
With regards, Alexander Moskalev
irker@irker.net
irker@php.net
a.moskalev@corp.badoo.com