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

Tips: encrypting local to remote(S3) #14

Open
mikkame opened this issue Feb 1, 2021 · 1 comment
Open

Tips: encrypting local to remote(S3) #14

mikkame opened this issue Feb 1, 2021 · 1 comment

Comments

@mikkame
Copy link

mikkame commented Feb 1, 2021

$crypt = new FileEncrypter(config('file-vault.key'), config('file-vault.cipher'));
$crypt->encrypt('local-path', 's3://bucket-name/path');

It working in my case.

@mikkame mikkame changed the title Tips encrypting local to remote(S3) Tips: encrypting local to remote(S3) Feb 1, 2021
@alexc-wormhole
Copy link

Additional tips if you're using multi-tenancy and don't want to use the Storage facade, This will take the file upload (/tmp/12345) and encrypt the contents into a temporary file for the request (/tmp/abcdef), then upload it afterwards.

use SoareCostin\FileVault\FileEncrypter;
use Illuminate\Support\Str;
use \Storage;

    $save_as = (string)Str::uuid() . '.' . strtolower($this->request->file('blob')->getClientOriginalExtension()); // my_photo.JPEG

    $temporary = tmpfile();

    $encrypter = new FileEncrypter (config('file-vault.key'), config('file-vault.cipher'));
    $encrypter->encrypt ($this->request->file('blob')->path(), stream_get_meta_data($temporary)['uri']);

    Storage::disk ($this->disk)->put ($this->folder_prefix.'/'.$save_as, stream_get_meta_data($temporary)['uri']);

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

No branches or pull requests

2 participants