Skip to content

Commit 72874de

Browse files
committed
add doc
1 parent 4047401 commit 72874de

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

README.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,12 @@ class Channel extends Model implements InteractWithMedia
249249

250250
### Adding Media
251251

252-
Add media to your model from various sources:
252+
Add media to your model, using the `addMedia` method, from various sources:
253+
254+
- an url
255+
- a resource or stream
256+
- a \Illuminate\Http\UploadedFile instance
257+
- a \Illuminate\Http\File instance
253258

254259
#### From a Controller
255260

@@ -267,7 +272,6 @@ public function store(Request $request, Channel $channel)
267272
} catch (InvalidMimeTypeException $exception){
268273
// Will throw an error if the mime type is not included in the collection's `acceptedMimeTypes` parameter.
269274
}
270-
271275
}
272276
```
273277

@@ -300,6 +304,22 @@ class ImageUploader extends Component
300304
}
301305
```
302306

307+
#### From an Url
308+
309+
```php
310+
use Elegantly\Media\Exceptions\InvalidMimeTypeException;
311+
312+
try {
313+
$channel->addMedia(
314+
file: "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4",
315+
collectionName: 'videos',
316+
name: "BigBuckBunny"
317+
);
318+
} catch (InvalidMimeTypeException $exception){
319+
// Will throw an error if the mime type is not included in the collection's `acceptedMimeTypes` parameter.
320+
}
321+
```
322+
303323
### Retreiving Media
304324

305325
Retrieve media from your model:

0 commit comments

Comments
 (0)