public function importIncomingFile($filename, $fr = false)
    {
        $fh = $this->app->make('helper/validation/file');
        if (!$fh->extension($filename)) {
            return self::E_FILE_INVALID_EXTENSION;
        }
        $incoming = $this->app->make(Incoming::class);
        $incomingStorageLocation = $incoming->getIncomingStorageLocation();
        $incomingFilesystem = $incomingStorageLocation->getFileSystemObject();
        $incomingPath = $incoming->getIncomingPath();
        if (!$incomingFilesystem->has($incomingPath . '/' . $filename)) {
            return self::E_FILE_INVALID;
        }
        if ($fr instanceof FileEntity) {
            $destinationStorageLocation = $fr->getFileStorageLocationObject();
        } else {
            $destinationStorageLocation = $this->app->make(StorageLocationFactory::class)->fetchDefault();
        }
        $destinationFilesystem = $destinationStorageLocation->getFileSystemObject();
        $prefix = $this->generatePrefix();
        $fi = $this->app->make('helper/file');
        $sanitizedFilename = $fi->sanitize($filename);
        $cf = $this->app->make('helper/concrete/file');
        $destinationPath = $cf->prefix($prefix, $sanitizedFilename);
        try {
            $stream = $incomingFilesystem->readStream($incomingPath . '/' . $filename);
        } catch (Exception $x) {
            $stream = false;
        }
        if ($stream === false) {
            return self::E_FILE_INVALID;
        }
        try {
            $wrote = $destinationFilesystem->writeStream($destinationPath, $stream);
        } catch (Exception $x) {
            $wrote = false;
        }
        @fclose($stream);
        if ($wrote === false) {
            return self::E_FILE_UNABLE_TO_STORE;
        }
        if (!($fr instanceof FileEntity)) {
            // we have to create a new file object for this file version
            $fv = File::add($sanitizedFilename, $prefix, ['fvTitle' => $filename], $destinationStorageLocation, $fr);
            $fv->refreshAttributes($this->rescanThumbnailsOnImport);

            foreach ($this->importProcessors as $processor) {
                if ($processor->shouldProcess($fv)) {
                    $processor->process($fv);
                }
            }
        } else {
            // We get a new version to modify
            $fv = $fr->getVersionToModify(true);
            $fv->updateFile($sanitizedFilename, $prefix);
            $fv->refreshAttributes($this->rescanThumbnailsOnImport);
        }

        return $fv;
    }