first commit

This commit is contained in:
2024-04-01 09:54:43 +08:00
commit 899d816bc3
795 changed files with 130040 additions and 0 deletions

View File

@@ -0,0 +1,75 @@
<?php
namespace Yeepay\Yop\Sdk\Internal;
use Psr\Http\Message\StreamInterface;
use Yeepay\Yop\Sdk\Utils\ObjectSerializer;
class MultiPartFile
{
/**
* @var string
*/
private $fileName;
/**
* @var StreamInterface
*/
private $content;
/**
* MultiPartFile constructor.
* @param string|resource $file
*/
public function __construct($file)
{
if (is_string($file)) {
$this->fileName = ObjectSerializer::sanitizeFilename($file);
$this->content = \GuzzleHttp\Psr7\Utils::streamFor($file);
} else {
$meta_data = stream_get_meta_data($file);
$this->fileName = ObjectSerializer::sanitizeFilename($meta_data['uri']);
$this->content = \GuzzleHttp\Psr7\Utils::streamFor($file);
}
}
/**
* @return string
*/
public function getFileName()
{
return $this->fileName;
}
/**
* @param string $fileName
* @return MultiPartFile
*/
public function setFileName($fileName)
{
$this->fileName = $fileName;
return $this;
}
/**
* @return StreamInterface
*/
public function getContent()
{
return $this->content;
}
/**
* @param StreamInterface $content
* @return MultiPartFile
*/
public function setContent($content)
{
$this->content = $content;
return $this;
}
}