|
1 | | - |
2 | | - |
3 | 1 | # 🛡️Simple Laravel Encrypt Upload File |
| 2 | + |
4 | 3 | [](https://scrutinizer-ci.com/g/irfaardy/encrypt-file-laravel/?branch=master) [](https://scrutinizer-ci.com/g/irfaardy/encrypt-file-laravel/build-status/master) [](https://packagist.org/packages/irfa/encrypt-file-laravel) [](https://github.com/irfaardy/encrypt-file-laravel/blob/master/LICENSE) [](https://www.buymeacoffee.com/OBaAofN) |
5 | 4 |
|
6 | 5 | <p>The Simple Laravel Encrypt Upload File uses the default encryption of Laravel which is implemented in upload file.<p> |
7 | 6 | <h3>🛠️ Installation with Composer </h3> |
8 | 7 |
|
9 | | - composer require irfa/encrypt-file-laravel |
| 8 | + |
| 9 | +```php |
| 10 | +composer require irfa/encrypt-file-laravel |
| 11 | +``` |
10 | 12 |
|
11 | 13 | >You can get Composer [ here]( https://getcomposer.org/download/) |
12 | 14 |
|
|
17 | 19 |
|
18 | 20 | <h3>Add to config/app.php</h3> |
19 | 21 |
|
20 | | - 'providers' => [ |
21 | | - .... |
22 | | - Irfa\FileSafe\FileSafeServiceProvider::class, |
23 | | - ]; |
| 22 | +```php |
| 23 | +'providers' => [ |
| 24 | + .... |
| 25 | + Irfa\FileSafe\FileSafeServiceProvider::class, |
| 26 | + ]; |
| 27 | +``` |
24 | 28 |
|
25 | 29 |
|
26 | 30 |
|
27 | 31 | <h3>Add to config/app.php</h3> |
28 | 32 |
|
29 | | - 'aliases' => [ |
30 | | - .... |
31 | | - 'FileSafe' => Irfa\FileSafe\Facades\FileSafe::class, |
32 | | - |
33 | | - ], |
| 33 | +```php |
| 34 | +'aliases' => [ |
| 35 | + .... |
| 36 | + 'FileSafe' => Irfa\FileSafe\Facades\FileSafe::class, |
| 37 | + |
| 38 | + ], |
| 39 | +``` |
34 | 40 |
|
35 | 41 | <h2>Publish Vendor</h2> |
36 | 42 |
|
|
44 | 50 | <h2>Example store file</h2> |
45 | 51 |
|
46 | 52 |
|
47 | | - <?php |
48 | | - |
49 | | - namespace App\Http\Controllers; |
50 | | - |
51 | | - use Filesafe; |
52 | | - use Illuminate\Http\Request; |
53 | | - use App\Http\Controllers\Controller; |
54 | | - |
55 | | - class FileController extends Controller |
| 53 | +```php |
| 54 | +<?php |
| 55 | + |
| 56 | +namespace App\Http\Controllers; |
| 57 | + |
| 58 | +use Filesafe; |
| 59 | +use Illuminate\Http\Request; |
| 60 | +use App\Http\Controllers\Controller; |
| 61 | + |
| 62 | +class FileController extends Controller |
| 63 | +{ |
| 64 | + |
| 65 | + public function upload_file(Request $request) |
56 | 66 | { |
57 | | - |
58 | | - public function upload_file(Request $request) |
59 | | - { |
60 | | - $file = $request->file('file'); |
61 | | - FileSafe::store($file); |
62 | | - //This is to encrypt the file before it is uploaded to the server. |
63 | | - |
64 | | - } |
| 67 | + $file = $request->file('file'); |
| 68 | + FileSafe::store($file); |
| 69 | + //This is to encrypt the file before it is uploaded to the server. |
| 70 | + |
65 | 71 | } |
| 72 | +} |
| 73 | +``` |
66 | 74 |
|
67 | 75 | <h2>Example download file</h2> |
68 | 76 |
|
69 | 77 |
|
70 | | - <?php |
71 | | - |
72 | | - namespace App\Http\Controllers; |
73 | | - |
74 | | - use FileSafe; |
75 | | - use Illuminate\Http\Request; |
76 | | - use App\Http\Controllers\Controller; |
77 | | - |
78 | | - class FileController extends Controller |
79 | | - { |
80 | | - |
81 | | - public function upload_file(Request $request) |
82 | | - { |
83 | | - $file = 'encrypted_file.txt'; |
84 | | - return FileSafe::download($file); |
85 | | - //decrypt file to be downloaded. |
86 | | - } |
87 | | - } |
| 78 | +```php |
| 79 | +... |
| 80 | + $file = 'path/to/encrypted_file.txt'; |
| 81 | + return FileSafe::download($file); |
| 82 | + //decrypt file to be downloaded. |
| 83 | +... |
| 84 | +``` |
88 | 85 |
|
89 | 86 | <h3>View Raw File</h3> |
90 | 87 |
|
91 | | - ... |
92 | | - $file = 'encrypt_file.txt'; |
93 | | - return FileSafe::file($file)->raw(); |
94 | | -... |
| 88 | +```php |
| 89 | +... |
| 90 | + $file = 'encrypt_file.txt'; |
| 91 | + return FileSafe::file($file)->raw(); |
| 92 | +... |
| 93 | +``` |
95 | 94 |
|
96 | 95 | <h2>Contribution</h2> |
| 96 | + |
97 | 97 | ENG:<br> |
98 | 98 | If you want to contribute this project and make it better, your help is very welcome.<br> |
99 | 99 | IDN:<br> |
100 | 100 | Jika Anda ingin berkontribusi dalam proyek ini dan menjadikannya lebih baik, bantuan Anda sangat kami harapkan. |
101 | | - |
102 | | -*** |
0 commit comments