Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

streamDecrypt ignoring "disk" #10

Open
richard-aio opened this issue Dec 26, 2020 · 1 comment · May be fixed by #15
Open

streamDecrypt ignoring "disk" #10

richard-aio opened this issue Dec 26, 2020 · 1 comment · May be fixed by #15

Comments

@richard-aio
Copy link

richard-aio commented Dec 26, 2020

When streaming the response from an S3 instance (DigitalOcean Spaces, using S3 driver), the disk is ignored and FileValue attempts to ready directly from the local disk:

        $encFilePath = $tomeUser->tome->id . '/' . $image->filename . '.enc';

        // Return the Image
        return response()->streamDownload(function () use ($image, $tomeUser, $encFilePath) {
            return FileVault::key($tomeUser->tome->key)
                ->disk('spaces')
                ->streamDecrypt($encFilePath);
        }, $image->filename);

As you can see in the log file, FileVault is using fopen() in my local directory:

[2020-12-26 14:24:19] local.ERROR: fopen(1/1608990767-5fe7402fa827b.png.enc): failed to open stream: No such file or directory {"userId":1,"exception":"[object] (ErrorException(code: 0): fopen(1/1608990767-5fe7402fa827b.png.enc): failed to open stream: No such file or directory at /Users/{name}/sites/{project}/vendor/soarecostin/file-vault/src/FileEncrypter.php:181)
[stacktrace]
#0 [internal function]: Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(2, 'fopen(1/1608990...', '/Users/{user}/...', 181, Array)
#1 /Users/{user}/sites/{project}/vendor/soarecostin/file-vault/src/FileEncrypter.php(181): fopen('1/1608990767-5f...', 'r', false, Resource id #13)
#2 /Users/{user}/sites/{project}/vendor/soarecostin/file-vault/src/FileEncrypter.php(128): SoareCostin\\FileVault\\FileEncrypter->openSourceFile('1/1608990767-5f...')
#3 /Users/{user}/sites/{project}/vendor/soarecostin/file-vault/src/FileVault.php(161): SoareCostin\\FileVault\\FileEncrypter->decrypt('1/1608990767-5f...', 'php://output')
#4 /Users/{user}/sites/{project}/app/Http/Controllers/ImageController.php(73): SoareCostin\\FileVault\\FileVault->streamDecrypt('1/1608990767-5f...')
#5 /Users/{user}/sites/{project}/vendor/symfony/http-foundation/StreamedResponse.php(109): App\\Http\\Controllers\\ImageController->App\\Http\\Controllers\\{closure}()
#6 /Users/{user}/sites/{project}/vendor/symfony/http-foundation/Response.php(394): Symfony\\Component\\HttpFoundation\\StreamedResponse->sendContent()
#7 /Users/{user}/sites/{project}/vendor/laravel/framework/src/Illuminate/Support/HigherOrderTapProxy.php(34): Symfony\\Component\\HttpFoundation\\Response->send()
#8 /Users/{user}/sites/{project}/public/index.php(53): Illuminate\\Support\\HigherOrderTapProxy->__call('send', Array)
#9 /Users/{user}/.composer/vendor/laravel/valet/server.php(214): require('/Users/{user}/...')
#10 {main}
"} 
@richard-aio
Copy link
Author

I can see the issue is that "s3" is hard coded in the solution as the disk name, instead of using the configuration for the disk driver.

If I get time over the next few days I will submit a pull request to resolve the issue.

@greimers greimers linked a pull request Feb 25, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant