Model/UploadableTrait.php
public function setFile(File $file = null)
    {
        $this->file = $file;

        if (null !== $file && !$this->hasRename()) {
            if ($this->hasPath()) {
                $this->rename = pathinfo($this->path, PATHINFO_BASENAME);
            } elseif ($file instanceof UploadedFile) {
                $this->rename = $file->getClientOriginalName();
            } elseif ($file instanceof File) {
                $this->rename = $file->getBasename();
            }
            $this->setUpdatedAt(new \DateTime());
        }

        return $this;
    }
public function setFile(File $file = null)
    {
        $this->file = $file;

        if (null !== $file && !$this->hasRename()) {
            if ($this->hasPath()) {
                $this->rename = pathinfo($this->path, PATHINFO_BASENAME);
            } elseif ($file instanceof UploadedFile) {
                $this->rename = $file->getClientOriginalName();
            } elseif ($file instanceof File) {
                $this->rename = $file->getBasename();
            }
            $this->setUpdatedAt(new \DateTime());
        }

        return $this;
    }
Set file

@param File $file
@return UploadableTrait|$this