| 1: | <?php declare(strict_types=1); |
| 2: | |
| 3: | namespace Salient\Curler; |
| 4: | |
| 5: | use Salient\Http\Message\StreamPart; |
| 6: | use Salient\Utility\File; |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | class CurlerFile extends StreamPart |
| 14: | { |
| 15: | |
| 16: | |
| 17: | |
| 18: | |
| 19: | |
| 20: | |
| 21: | |
| 22: | public function __construct( |
| 23: | string $filename, |
| 24: | ?string $uploadFilename = null, |
| 25: | ?string $mediaType = null, |
| 26: | ?string $asciiFilename = null, |
| 27: | ?string $name = null |
| 28: | ) { |
| 29: | parent::__construct( |
| 30: | File::open($filename, 'r'), |
| 31: | $name, |
| 32: | $uploadFilename ?? basename($filename), |
| 33: | self::filterFileMediaType($mediaType, $filename), |
| 34: | $asciiFilename, |
| 35: | ); |
| 36: | } |
| 37: | } |
| 38: | |