private function MultipartStream::createElement in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/guzzlehttp/psr7/src/MultipartStream.php \GuzzleHttp\Psr7\MultipartStream::createElement()
Return value
array
1 call to MultipartStream::createElement()
- MultipartStream::addElement in vendor/
guzzlehttp/ psr7/ src/ MultipartStream.php
File
- vendor/
guzzlehttp/ psr7/ src/ MultipartStream.php, line 111
Class
- MultipartStream
- Stream that when read returns bytes for a streaming multipart or multipart/form-data stream.
Namespace
GuzzleHttp\Psr7Code
private function createElement($name, $stream, $filename, array $headers) {
// Set a default content-disposition header if one was no provided
$disposition = $this
->getHeader($headers, 'content-disposition');
if (!$disposition) {
$headers['Content-Disposition'] = $filename ? sprintf('form-data; name="%s"; filename="%s"', $name, basename($filename)) : "form-data; name=\"{$name}\"";
}
// Set a default content-length header if one was no provided
$length = $this
->getHeader($headers, 'content-length');
if (!$length) {
if ($length = $stream
->getSize()) {
$headers['Content-Length'] = (string) $length;
}
}
// Set a default Content-Type if one was not supplied
$type = $this
->getHeader($headers, 'content-type');
if (!$type && $filename) {
if ($type = mimetype_from_filename($filename)) {
$headers['Content-Type'] = $type;
}
}
return [
$stream,
$headers,
];
}