public function move(Media $media, $directory, $filename = null)
    {
        $storage = $this->filesystem->disk($media->disk);

        if ($filename) {
            $filename = $this->removeExtensionFromFilename($filename, $media->extension);
        } else {
            $filename = $media->filename;
        }

        $directory = trim($directory, '/');
        $target_path = $directory.'/'.$filename.'.'.$media->extension;

        if ($storage->has($target_path)) {
            throw MediaMoveException::destinationExists($target_path);
        }

        $storage->move($media->getDiskPath(), $target_path);

        $media->filename = $filename;
        $media->directory = $directory;
        $media->save();
    }