diff --git a/.travis.yml b/.travis.yml index 8d48350..bc13fc5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,9 @@ language: php php: - - 7.1 - - 7.2 - - 7.3 + - '7.1' + - '7.2' + - '7.3' env: matrix: @@ -17,9 +17,9 @@ before_install: install: - travis_retry composer update ${COMPOSER_FLAGS} --no-interaction - - sudo add-apt-repository -y ppa:mc3man/trusty-media + - sudo add-apt-repository -y ppa:mc3man/xerus-media - sudo apt-get -qq update - sudo apt-get install -y --allow-unauthenticated software-properties-common ffmpeg script: - - phpunit + - ./vendor/bin/phpunit diff --git a/composer.json b/composer.json index 811c2e7..9743e0a 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,8 @@ }, "require-dev": { "mockery/mockery": "^1.0", - "phpunit/phpunit": "7.5" + "phpunit/phpunit": "7.5", + "twistor/flysystem-http": "^0.2.0" }, "autoload": { "psr-4": { diff --git a/src/Disk.php b/src/Disk.php index 3f94cfe..bb93393 100644 --- a/src/Disk.php +++ b/src/Disk.php @@ -6,6 +6,7 @@ use League\Flysystem\Adapter\Local as LocalAdapater; /** + * @method \League\Flysystem\FilesystemInterface getDriver() * @method bool put($path, $contents, $visibility = null) * @method array|false read($path) * @method void setVisibility($path, $visibility) diff --git a/src/FFMpeg.php b/src/FFMpeg.php index 11148f5..59a3895 100644 --- a/src/FFMpeg.php +++ b/src/FFMpeg.php @@ -77,7 +77,11 @@ public function open($path): Media $ffmpegPathFile = $file->getFullPath(); } else { $ffmpegPathFile = static::newTemporaryFile(); - file_put_contents($ffmpegPathFile, $this->disk->read($path)); + + stream_copy_to_stream( + $this->disk->getDriver()->readStream($path), + fopen($ffmpegPathFile, 'w') + ); } $ffmpegMedia = $this->ffmpeg->open($ffmpegPathFile); diff --git a/tests/AudioVideoTest.php b/tests/AudioVideoTest.php index fd08b03..1124e74 100644 --- a/tests/AudioVideoTest.php +++ b/tests/AudioVideoTest.php @@ -25,6 +25,7 @@ use Pbmedia\LaravelFFMpeg\File; use Pbmedia\LaravelFFMpeg\Media; use Pbmedia\LaravelFFMpeg\MediaExporter; +use Twistor\Flysystem\Http\HttpAdapter; class AudioVideoTest extends TestCase { @@ -197,16 +198,10 @@ public function testOpeningFromRemoteDisk() $config = Mockery::mock(ConfigRepository::class); $logger = new Writer(new Logger('ffmpeg')); - $adapter = Mockery::mock(AdapterInterface::class); + $adapter = new HttpAdapter("https://raw.githubusercontent.com/pascalbaljetmedia/laravel-ffmpeg/master/tests/src/"); + $driver = new \League\Flysystem\Filesystem($adapter); - $driver = Mockery::mock(FilesystemInterface::class); - $driver->shouldReceive('getAdapter')->andReturn($adapter); - - $remoteDisk = Mockery::mock(FilesystemAdapter::class); - $remoteDisk->shouldReceive('getDriver')->andReturn($driver); - $remoteDisk->shouldReceive('read')->with('remote_guitar.m4a')->andReturn( - $videoContents = file_get_contents(__DIR__ . '/src/guitar.m4a') - ); + $remoteDisk = new FilesystemAdapter($driver); $localDisk = $this->getLocalAdapter(); @@ -217,7 +212,7 @@ public function testOpeningFromRemoteDisk() $config->shouldReceive('get')->once()->with('filesystems.default')->andReturn('s3'); $service = new FFMpeg($filesystems, $config, $logger); - $media = $service->open('remote_guitar.m4a'); + $media = $service->open('guitar.m4a'); $format = new \FFMpeg\Format\Audio\Aac;