file-vault
file-vault copied to clipboard
Tips: encrypting local to remote(S3)
$crypt = new FileEncrypter(config('file-vault.key'), config('file-vault.cipher'));
$crypt->encrypt('local-path', 's3://bucket-name/path');
It working in my case.
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']);