# PR 1217: Add support for upload files from buffer string in curl extenion

- Thread: https://externals.io/message/85952
- Original archive: https://news-web.php.net/php.internals/85952
- Started by kelerest123@gmail.com on 2015-04-26T15:33:15+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #85952 — kelerest123@gmail.com — 2015-04-26T15:33:15+00:00

URL: https://externals.io/message/85952#85952

Hey Alexander!

2015-04-22 10:26 GMT+02:00 Alexander Moskalev <irker@irker.net>:

> Jakub, I think about static factory methods, but not sure if it will be
> great.
>  I think using empty constructor more clear.
>

So we can add a setter, which, however, will return $this, to allow
chaining and prevent one redundant line of code:

<?php

$fileBuffer = (new CURLFile)->setBuffer('some file contents');
// ($fileBuffer instanceof CURLFile) === true

But this looks a bit weird and for some people also confusing. Thus it
would be even better to have a static factory method, I think.


Best regards,
Kubo2

---

## #86141 — Alexander Moskalev — 2015-05-08T20:08:22+00:00

URL: https://externals.io/message/85952#86141 · In reply to: #85952

Hi!

I try rewrite feature to use exists class:
https://github.com/php/php-src/commit/6319f954ca0674c77bb1f8f8409c9ac841fe301d

Please, take a look at this commit.

1) constructor does not require params
2) added curl_buffer_file_create function (like curl_file_create)
3) setters changed to allow binary data. May be it isn't good idea, but all
properties already have public access, so we can already set bad values. So
it just make common behavior for setters and manual setting properties.
4) If file name cast to true and contain a string - we use it.
5) If it still cast to true, but contain not a string - we report error
6) If file name cast to false - we use buffer

Please, check my commit and later I will create new pull request.

Thank you!




-- 
With regards, Alexander Moskalev
irker@irker.net
irker@php.net
a.moskalev@corp.badoo.com

---

## #86264 — Alexander Moskalev — 2015-05-16T20:24:26+00:00

URL: https://externals.io/message/85952#86264 · In reply to: #86141

Hi!

PR: https://github.com/php/php-src/pull/1283

-- 
With regards, Alexander Moskalev
irker@irker.net
irker@php.net
a.moskalev@corp.badoo.com
