@param string|UploadedFile|null $filePath
@param string|null              $disk
@param string|null              $readerType

@throws NoFilePathGivenException
@return Collection
518686
public function toCollection($filePath = null, string $disk = null, string $readerType = null): Collection
    {
        $filePath = $this->getFilePath($filePath);

        return $this->getImporter()->toCollection(
            $this,
            $filePath,
            $disk ?? $this->disk ?? null,
            $readerType ?? $this->readerType ?? null
        );
    }
1281140
public function upload($filePath, $contentType = 'text/plain')
    {
        $fileName = $this->path . '/' . $this->getFilePathAndUniquePrefix() . basename($filePath);

        (new Filesystem)->copy($filePath, $fileName);

        return $fileName;
    }
440250
public <X> DataSource<X> readFile(FileInputFormat<X> inputFormat, String filePath) {
		if (inputFormat == null) {
			throw new IllegalArgumentException("InputFormat must not be null.");
		}
		if (filePath == null) {
			throw new IllegalArgumentException("The file path must not be null.");
		}

		inputFormat.setFilePath(new Path(filePath));
		try {
			return createInput(inputFormat, TypeExtractor.getInputFormatTypes(inputFormat));
		}
		catch (Exception e) {
			throw new InvalidProgramException("The type returned by the input format could not be automatically determined. " +
					"Please specify the TypeInformation of the produced type explicitly by using the " +
					"'createInput(InputFormat, TypeInformation)' method instead.");
		}
	}
617750
public function importFile($filepath, $colmap = null, $hasheader = true, $cleardata = false)
    {
        $loader = $this->component->getLoader($this->gridField);
        $loader->deleteExistingRecords = $cleardata;

        //set or merge in given col map
        if (is_array($colmap)) {
            $loader->columnMap = $loader->columnMap ?
                array_merge($loader->columnMap, $colmap) : $colmap;
        }
        $loader->getSource()
            ->setFilePath($filepath)
            ->setHasHeader($hasheader);

        return $loader->load();
    }
878918
public function addAttachment ($filePath = FALSE, $fileName = NULL, $fileData = FALSE, $mimeType = 'text/plain')
    {

        // If its an existing file

        if ($filePath !== FALSE)
        {

            // Check File Exists

            if (!file_exists ($filePath))
            {

                // Add error and return false

                new \Sonic\Message ('error', $filePath . ' doesnt exist!');
                return FALSE;

            }

            // Get MIME Type

            $objFinfo   = new finfo;

            if (!$mimeType = $objFinfo->file ($filePath, FILEINFO_MIME))
            {

                // Add error and return false

                new \Sonic\Message ('error', 'Cannot get MIME type!');
                return FALSE;

            }

            // Get File Data

            if (!$fileData = @file_get_contents ($filePath))
            {

                // Add error and return false

                new \Sonic\Message ('error', 'Cannot get attachment data!');
                return FALSE;

            }

        }
        else if (!$fileData || !$fileName)
        {

            // Add error and return false

            new \Sonic\Message ('error', 'Invalid Attachment!');
            return FALSE;

        }

        // Set attachments boolean

        $this->_attachmentsSet	= TRUE;

        // Add Attachment

        $this->_attachments[]	= array (
            'name'		=> $fileName,
            'data'		=> $fileData,
            'type'		=> $mimeType
        );

        // Return TRUE

        return TRUE;

    }
668820
function readFiles (filepaths, callback) {
  async.map(filepaths, readFile.bind(this), function (err, files) {

    if (err) callback(err);

    callback(null, files);
  });
}
7937
protected function uploadTemp($filePath, $type)
    {
        $url = sprintf(self::MEDIA_TEMP_UPLOAD_URL, $this->getAccessTokenString(), $type);
        $client = $this->getHttpClient();
        $client->setUrl($url);
        $client->setMethod(Client::METHOD_UPLOAD);

        $basename = basename($filePath);

        $client->setPostDataArray([ 'media'          => curl_file_create($filePath),
                                    'filename'      => $basename,
                                    'filelength'    => filesize($filePath),
                                    'content-type'  => $this->getUpLoadContentType($type),
                                    'hack'          => '',
                                    ]);
        if (!$client->exec()) {
            throw new Exception("call send custom service message fail");
        }

        $result = json_decode($client->getResponse(), true);

        if (isset($result['errcode'])) {
            throw new Exception("error response for upload Temp info " . $result['errcode'] . ' ' . $result['errmsg']);
        }

        return $result;
    }
1250822
public function readFromFile($filepath, $delimiter = "\t")
    {
        $reader = new CsvReader($filepath, $delimiter);
        $this->tokensReadFromFile = [];
        while (($line = $reader->getLine()) !== null) {
            if (!$reader->isEmpty($line)) {
                $this->tokensReadFromFile[] = $line[0]; // we expect the token in the first column
                // the second column might contain further info such as "use this many times"
            }
        }
    }
1276972
protected function getFileAsset($filePath)
    {
        $file = new \SplFileInfo($filePath);

        if (!$file->isReadable() || $file->isDir()) {
            return null;
        }

        $filePath = $file->getRealPath();

        return new FileAsset($filePath);
    }
221956
public function readFile($filePath = null, array $options = [])
    {
        $filePath = empty($filePath)
            ? $this->filePath
            : $filePath;

        $result = new ArrayIterator();

        if (false !== ($contents = json_decode(file_get_contents($filePath), true))) {
            if (json_last_error() === JSON_ERROR_NONE) {
                foreach ($contents as $content) {
                    $result[] = new SplArrayObject($content);
                }
            }
        }

        return $result;
    }
379736
public function queue($filePath = null, string $disk = null, string $readerType = null)
    {
        if (!$this instanceof ShouldQueue) {
            throw new InvalidArgumentException('Importable should implement ShouldQueue to be queued.');
        }

        return $this->import($filePath, $disk, $readerType);
    }
66766
public function readFile($filePath = null, array $options = [])
    {
        $items = parse_ini_file(
            $filePath,
            (empty($options)
                ? true
                : $options[ 'sections' ])
        );

        $this->merge($items);

        return $items;
    }
822128
public static function loadFromPhpFile(string $filePath): DataMap
    {
        if (! is_file($filePath)) {
            throw new CoreException(CoreException::FILE_NOT_FOUND, '找不到php文件: ' . $filePath, $filePath);
        }
        $data = include $filePath;
        return new static($data);
    }
475539
public static function getReader($filePath)
    {
        $xmlReader = new \SimpleXMLElement($filePath, null, true);
        
        switch ($xmlReader->attributes()->version) {
            case '1.1.0':
                return new MzIdentMlReader1r1($filePath);
            case '1.2.0':
                return new MzIdentMlReader1r2($filePath);
            default:
                throw new \UnexpectedValueException('Version ' . $xmlReader->attributes()->version . ' is not supported');
        }
    }
875912
final public function createFile($filePath = null)
    {
        if (isset($filePath)) {
            $this->filePath = $filePath;
        }

        if (pathinfo($this->filePath, PATHINFO_EXTENSION) === '') {
            $this->filePath .= $this->fileExtension;
        }

        return $this;
    }
633335
public function toArray($import, $file, string $disk = null, string $readerType = null): array
    {
        $filePath = ($file instanceof UploadedFile) ? $file->getFilename() : $file;

        $this->imported[$disk ?? 'default'][$filePath] = $import;

        return [];
    }
1172903
public function openFileAsArray(string $filepath):array
    {
        if ($filepath == $this->filepath && $this->file != null) {
            return ($this->file);
        }

        if (!file_exists($filepath)) {
            Server::create($filepath, 'file');
        }

        if (!is_readable($filepath)) {
            throw new Server500(new \ArrayObject(array("explain" =>
                "Cannot open file $filepath : File not readable",
                "solution" => "Please set the readable permission")));
        }

        $this->perm = null;
        $this->filepath = $filepath;
        $this->file = file($filepath);

        if (!is_array($this->file)) {
            throw new Server500(new \ArrayObject(array("explain" =>
                "Invalid file array for $filepath",
                "solution" =>
                    "Use FileListener::open to open a file resource.")));
        }

        return ($this->file);
    }