Skip to content

Commit 156712e

Browse files
committed
Update readme.md
1 parent 0bee980 commit 156712e

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

readme.md

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ Laravel File API is good way to handle files with Laravel Storage.
88

99
1. Install File API
1010

11-
composer require unisharp/laravel-fileapi
11+
composer require unisharp/laravel-fileapi
1212

1313
1. Set service provider in `config/app.php`
1414

1515
```php
16-
Unisharp\FileApi\FileApiServiceProvider::class,
16+
Unisharp\FileApi\FileApiServiceProvider::class,
1717
```
1818

1919
1. publish config file
2020

21-
php artisan vendor:publish --tag=fileapi_config
21+
php artisan vendor:publish --tag=fileapi_config
2222

2323
### Config
2424

@@ -27,79 +27,79 @@ in `config/fileapi.php`
2727
1. fill in the storage path, which make routes for you.
2828

2929
```php
30-
'path' => ['/images/event/', '/images/article/'],
30+
'path' => ['/images/event/', '/images/article/'],
3131
```
3232

3333
it will generate routes like below :
3434

3535
```php
36-
Route::get('/images/event/{filename}', function ($filename) {
37-
$entry = new \Unisharp\FileApi\FileApi('/images/event/');
38-
return $entry->getResponse($filename);
39-
});
40-
41-
Route::get('/images/article/{filename}', function ($filename) {
42-
$entry = new \Unisharp\FileApi\FileApi('/images/article/');
43-
return $entry->getResponse($filename);
44-
});
36+
Route::get('/images/event/{filename}', function ($filename) {
37+
$entry = new \Unisharp\FileApi\FileApi('/images/event/');
38+
return $entry->getResponse($filename);
39+
});
40+
41+
Route::get('/images/article/{filename}', function ($filename) {
42+
$entry = new \Unisharp\FileApi\FileApi('/images/article/');
43+
return $entry->getResponse($filename);
44+
});
4545
```
4646

4747
1. set default thumb sizes(by key and value)
4848

4949
```php
50-
'default_thumbs' => ['S' => '96x96', 'M' => '256x256', 'L' => '480x480'],
50+
'default_thumbs' => ['S' => '96x96', 'M' => '256x256', 'L' => '480x480'],
5151
```
5252

5353
### Initialize File API
5454

55-
```php
55+
```php
5656
use \Unisharp\FileApi\FileApi;
5757

5858
$fa = new FileApi();
59-
```
59+
```
6060

6161
or
6262

63-
```php
63+
```php
6464
$fa = new FileApi('/images/event/'); # initialize it by giving a base path
6565
$fa_article = new FileApi('/images/article/'); # initiate another instance
66-
```
66+
```
6767

6868

6969
### Save to Storage By Giving Uploaded File
7070

7171
* Default Usage : get unique filename
7272

7373
```php
74-
$file = $fa->save(\Input::file('main_image')); // => wfj412.jpg
74+
$file = $fa->save(\Input::file('main_image')); // => wfj412.jpg
7575
```
7676

7777
* Custimize your upload file name
7878

7979
```php
80-
$file = $fa->save(\Input::file('main_image'), 'custimized_filename'); // => custimized_filename.jpg
80+
$file = $fa->save(\Input::file('main_image'), 'custimized_filename'); // => custimized_filename.jpg
8181
```
8282

8383
### Save thumbnails
8484

8585
* By default will set three thumbs(equal scaling)
8686

8787
```php
88-
$file = $fa->save(\Input::file('main_image'));
88+
$file = $fa->save(\Input::file('main_image'));
8989
```
9090

9191
* Set custom thumb sizes
9292

9393
```php
94-
$file = $fa
95-
->thumbs(['S' => '150x100', 'M' => '300x200', 'L' => '450x300'])
96-
->save(\Input::file('main_image'));
94+
$file = $fa
95+
->thumbs(['S' => '150x100', 'M' => '300x200', 'L' => '450x300'])
96+
->save(\Input::file('main_image'));
9797
```
9898

9999
* make cropped thumbs
100100

101101
```php
102-
$file = $fa->crop()->save(\Input::file('main_image'));
102+
$file = $fa->crop()->save(\Input::file('main_image'));
103103
```
104104

105105
### Get file fullpath (abstract path from Laravel Storage)
@@ -121,17 +121,17 @@ you can use url() method to get it
121121
* Get file content
122122

123123
```php
124-
\Storage::get($fa->getPath('wfj412.jpg'));
124+
\Storage::get($fa->getPath('wfj412.jpg'));
125125
```
126126

127127
* Write files
128128

129129
```php
130-
\Storage::put($fa->getPath('wfj412.jpg'));
130+
\Storage::put($fa->getPath('wfj412.jpg'));
131131
```
132132

133133
* Get Mime Type
134134

135135
```php
136-
\Storage::mimeType($fa->getPath('wfj412.jpg'));
136+
\Storage::mimeType($fa->getPath('wfj412.jpg'));
137137
```

0 commit comments

Comments
 (0)