public function addFile($file, $type = '', $locale = null, $filename = null, $keepOriginal = false): void
    {
        if ($file instanceof Traversable || is_array($file)) {
            $this->addFiles($file, $type, $locale, $keepOriginal);
        } else {
            $locale = $this->normalizeLocaleString($locale);

            if (is_string($file)) {
                $asset = AssetUploader::uploadFromBase64($file, $filename, $keepOriginal);
            } else {
                $asset = AssetUploader::upload($file, $filename, $keepOriginal);
            }

            if ($asset instanceof Asset) {
                $asset->attachToModel($this, $type, $locale);
            }
        }
    }
public function addFile($file, $type = '', $locale = null, $filename = null, $keepOriginal = false): void
    {
        if ($file instanceof Traversable || is_array($file)) {
            $this->addFiles($file, $type, $locale, $keepOriginal);
        } else {
            $locale = $this->normalizeLocaleString($locale);

            if (is_string($file)) {
                $asset = AssetUploader::uploadFromBase64($file, $filename, $keepOriginal);
            } else {
                $asset = AssetUploader::upload($file, $filename, $keepOriginal);
            }

            if ($asset instanceof Asset) {
                $asset->attachToModel($this, $type, $locale);
            }
        }
    }
public function addFile ( $ file , $ type = '' , $ locale = null , $ filename = null , $ keepOriginal = false ) : void { if ( $ file instanceof Traversable || is_array ( $ file ) ) { $ this -> addFiles ( $ file , $ type , $ locale , $ keepOriginal ) ; } else { $ locale = $ this -> normalizeLocaleString ( $ locale ) ; if ( is_string ( $ file ) ) { $ asset = AssetUploader :: uploadFromBase64 ( $ file , $ filename , $ keepOriginal ) ; } else { $ asset = AssetUploader :: upload ( $ file , $ filename , $ keepOriginal ) ; } if ( $ asset instanceof Asset ) { $ asset -> attachToModel ( $ this , $ type , $ locale ) ; } } }
Adds a file to this model, accepts a type and locale to be saved with the file.

@param $file
@param string $type
@param string|null $locale
@param null $filename
@param bool $keepOriginal
@throws \Spatie\MediaLibrary\Exceptions\FileCannotBeAdded
@throws \Thinktomorrow\AssetLibrary\Exceptions\AssetUploadException
Adds a file to this model accepts a type and locale to be saved with the file .