diff --git a/src/MediaController.php b/src/MediaController.php index b10dabe..b140a7a 100644 --- a/src/MediaController.php +++ b/src/MediaController.php @@ -45,10 +45,12 @@ class MediaController $medias = collect($content)->map(function ($c) use ($collection, $model) { $pathinfo = pathinfo($c['name']); - $path = $collection->runCallback('forceFileName', $model, $pathinfo['filename']).'.'.$pathinfo['extension']; - Storage::disk('public')->put($path, base64_decode($c['content'])); + $basename = $collection->runCallback('forceFileName', $model, $pathinfo['filename']); + $path = $basename.'.'.$pathinfo['extension']; $adder = $model - ->addMedia(Storage::disk('public')->path($path)) + ->addMediaFromBase64($c['content']) + ->usingName($basename) + ->usingFileName($path) ->withCustomProperties($collection->runCallback('withDefaultProperties', $path)); return tap(