soarecostin/file-vault

streamDecrypt not working for custom disk using "S3" driver

muarachmann opened this issue · 1 comments

Using the code doesn't download the file.

       return
            response()->streamDownload(function () use ($decFilename) {
                FileVault::disk('s3')->streamDecrypt($decFilename);
            }, Str::replaceLast('.enc', '', basename($decFilename)));

I keep getting the error ** Failed to open stream: No such file or directory** meanwhile the upload to bucket works and the file is actually there in the bucket. Using Local bucket, it works fine but doesn't work with the s3 driver.

Update on this @soarecostin
I noticed it was because I am using a custom disk configuration. e.g

'test-disk' => [
            'driver' => 's3',
            'key' => env('AWS_ACCESS_KEY_ID'),
            'secret' => env('AWS_SECRET_ACCESS_KEY'),
            'region' => env('AWS_DEFAULT_REGION'),
            'bucket' => env('AWS_BUCKET'),
            'url' => env('AWS_URL'),
            'endpoint' => env('AWS_ENDPOINT'),
        ],

The streamDecrypt doesn't work as it fails to check if the disk is actually using the s3 driver here

return $this->disk == 's3';

here this->disk returns test-disk and thus fails with file not found.