Create a file upload authorization
@param string $dirName
@param string $FileName
@return int The new upload authorization id
773997
public function createAuthorization( $dirName, $FileName){
        $rest = $this->getService( self::API_UPLOAD);
        $rest->POST([
            'dirname'       => base64_encode( $dirName),
            'upload_name'   => $FileName,
        ]);

        return (int) $rest->getResult()['id'];
    }
346381
public function upload($binaryImage, $filename)
    {
        $targetFile = $this->getTargetPath($filename);
        $this->ensureDirectoryExists(dirname($targetFile));
        $this->filesystem->dumpFile($targetFile, $binaryImage);

        return $targetFile;
    }
414933
public static File createPictureFile(String dirName) {
        String timeStamp = IMG_FILE_NAME_FORMAT.format(new Date());
        String imageFileName = PREFIX_IMAGE + timeStamp + EXTENSION_JPEG;
        return new File(getPicturesDir(dirName), imageFileName);
    }
671809
public function rmdir(string $dirName): bool
    {
        return unlink($this->fileInfo->getAbsoluteFilePath() . MDir::getSeparator() . $dirName);
    }
451510
public function uploadUrlForFile($filename) {
	    $prefix = StorageSettings::prefix(null);
        $parts = explode('/', $filename);
        $bucketFilename = array_pop($parts);

		if($this->client && $this->client->enabled()) {
			try {
				return $this->client->uploadUrl($prefix.$bucketFilename, StorageSettings::privacy(), StorageSettings::cacheControl(), StorageSettings::expires());
			}
			catch(StorageException $ex) {
				Logger::error('Generate File Upload URL Error', ['exception' => $ex->getMessage()]);
			}
		}

		return null;
	}
811491
public static function createDir(string $dirname, string $visibility = 'public')
    {
        $umask = umask(0);

        if (!is_dir($dirname) && !mkdir($dirname, Filesystem::$permissions['dir'][$visibility], true)) {
            return false;
        }

        umask($umask);

        return true;
    }
1354309
private function _findFile(string $dirName, string $fileName): ?FileHandler {
        $dirs = glob($dirName . '*');
        $file = null;
        foreach ($dirs as $d) {
            if (is_file($d)) {
                $pathInfo = \pathinfo($d);
                $pathInfo2 = \pathinfo($fileName);

                if (isset($pathInfo2["extension"])) {
                    $condition = $pathInfo["basename"] === $pathInfo2["basename"];
                } else {
                    $condition = $pathInfo["filename"] === $pathInfo2["filename"];
                }

                if ($condition) {
                    return new FileHandler($dirName . "/" . $pathInfo["basename"]);
                }
            } else if (is_dir($d)) {
                $tmp = $this->_findFile($d . "/", $fileName);
                if (null !== $tmp) {
                    $file = $tmp;
                }
            }
        }
        return $file;
    }
42658
public function getPermittedFileName($directory, $filename) {

        /**
         * Get $pathInfo from $filename
         */
        $pathInfo = pathinfo($filename);

        /**
         * Max limit permitted $filename
         */
        $pathInfo['filename'] = substr(Inflector::slug($pathInfo['filename']), 0, 100);

        /**
         * Min limit permitted $filename
         */
        if (strlen($pathInfo['filename']) < 3)
            $pathInfo['filename'] = $this->_randomString();

        /**
         * 
         */
        $dir = new Folder($directory);
        $iter = 0;
        do {
            if ($iter == 0)
                $slugFileName = $pathInfo['filename'] . '.' . $pathInfo['extension'];
            else
                $slugFileName = $pathInfo['filename'] . '-' . $iter . '.' . $pathInfo['extension'];
            $data = $dir->find($slugFileName, true);
            $iter++;
        } while (count($data) > 0);

        return $slugFileName;
    }
1252212
public function setUploadpath($dir_name)
	{
		//set the value of upload_path property
		//set the upload path
		if($dir_name === null)	$this->upload_path = Registry::getConfig()['upload_path'];

		else $this->upload_path = $dir_name;
		
		return $this;
	}
139321
public static function download($filename, $showName = '', $speedLimit = 0, $dir = CML_PROJECT_PATH . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR)
    {
        if (!is_file($filename)) {
            $filename = $dir . $filename;
        }
        if (!is_file($filename)) {
            header("HTTP/1.1 404 Not Found");
            return false;
        }

        if (empty($showName)) {
            $showName = $filename;
        }
        $showName = basename($showName);

        $contentType = self::mimeContentType($filename);

        $fileStat = stat($filename);
        $lastModified = $fileStat['mtime'];
        $md5 = md5($fileStat['mtime'] . '=' . $fileStat['ino'] . '=' . $fileStat['size']);
        $etag = '"' . $md5 . '-' . crc32($md5) . '"';
        header('Last-Modified: ' . gmdate("D, d M Y H:i:s", $lastModified) . ' GMT');
        header("ETag: $etag");
        if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $lastModified) {
            header("HTTP/1.1 304 Not Modified");
            return true;
        }
        if (isset($_SERVER['HTTP_IF_UNMODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_UNMODIFIED_SINCE']) < $lastModified) {
            header("HTTP/1.1 304 Not Modified");
            return true;
        }
        if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag) {
            header("HTTP/1.1 304 Not Modified");
            return true;
        }

        $fileSize = $fileStat['size'];
        $contentLength = $fileSize;
        $isPartial = false;
        if (isset($_SERVER['HTTP_RANGE'])) {
            if (preg_match('/^bytes=(d*)-(d*)$/', $_SERVER['HTTP_RANGE'], $matches)) {
                $startPos = $matches[1];
                $endPos = $matches[2];
                if ($startPos == '' && $endPos == '') {
                    return false;
                }
                if ($startPos == '') {
                    $startPos = $fileSize - $endPos;
                    $endPos = $fileSize - 1;
                } else if ($endPos == '') {
                    $endPos = $fileSize - 1;
                }
                $startPos = $startPos < 0 ? 0 : $startPos;
                $endPos = $endPos > $fileSize - 1 ? $fileSize - 1 : $endPos;
                $length = $endPos - $startPos + 1;
                if ($length <= 0) {
                    return false;
                }
                $contentLength = $length;
                $isPartial = true;
            }
        }

        if ($isPartial) {
            header('HTTP/1.1 206 Partial Content');
            header("Content-Range: bytes {$startPos} - {$endPos} / {$fileSize}");
        } else {
            header("HTTP/1.1 200 OK");
            $startPos = 0;
            //$endPos = $contentLength - 1;
        }

        header('Pragma: cache');
        header('Cache-Control: public, must-revalidate, max-age=0');
        header('Accept-Ranges: bytes');
        header('Content-type: ' . $contentType);
        header('Content-Length: ' . $contentLength);
        header('Content-Disposition: attachment; filename="' . rawurlencode($showName) . '"');
        header("Content-Transfer-Encoding: binary");

        $bufferSize = 2048;
        if ($speedLimit != 0) {
            $packetTime = floor($bufferSize * 1000000 / $speedLimit);
        }
        $bytesSent = 0;
        $fp = fopen($filename, "rb");
        fseek($fp, $startPos);
        while ($bytesSent < $contentLength && !feof($fp) && connection_status() == 0) {
            if ($speedLimit != 0) {
                $outputTimeStart = microtime(true);
            }
            $readBufferSize = $contentLength - $bytesSent < $bufferSize ? $contentLength - $bytesSent : $bufferSize;

            $buffer = fread($fp, $readBufferSize);
            echo $buffer;
            $bytesSent += $readBufferSize;
            if ($speedLimit != 0) {
                $outputTimeEnd = microtime(true);
                $useTime = ((float)$outputTimeEnd - (float)$outputTimeStart) * 1000000;
                $sleepTime = round($packetTime - $useTime);
                if ($sleepTime > 0) {
                    usleep($sleepTime);
                }
            }
        }
        return true;
    }
973554
public static function createFile($filename)
    {
        if (is_file($filename)) return false;
        self::createDir(dirname($filename)); //创建目录
        return file_put_contents($filename,'');
    }
284261
public function create($filename, $content)
    {
        $filename = str::path($filename);

        $this->createDirectory(dirname($filename));

        return file_put_contents($filename, $content);
    }
439874
private function makeActualDirectory($dirname, $mode)
    {
        $listing = glob($this->current_working_dir . '/*', GLOB_ONLYDIR) ?: [];

        $directories = array_map(function ($value) {
            return pathinfo($value, PATHINFO_BASENAME);
        }, $listing);

        // Skip directory creation if it already exists
        if (in_array($dirname, $directories, true)) {
            return true;
        }

        return @mkdir($dirname, $mode);
    }
1251770
public function createFile($filename, $content)
    {
        if (false === $this->createDirectory(dirname($filename))) {
            return false;
        }

        Silencer::call('file_put_contents', $filename, $content);
        Silencer::call('chmod', $filename, 0755);

        return true;
    }
453569
public function setFilename($filename , $directory = null)
    {
        $this->filename  = $filename;
        $this->directory = $directory;
    }
731303
public static function recursiveDeleteDirectory(string $dirName): void {
		if (is_dir($dirName) && $dirArray = scandir($dirName)) {
			foreach ($dirArray as $k => $v) {
				if ($v !== '.' && $v !== '..') {
					if (is_dir($dirName . '/' . $v)) {
						static::recursiveDeleteDirectory($dirName . '/' . $v);
						rmdir($dirName . '/' . $v);
					}
					else
						unlink($dirName . '/' . $v);
				}
			}
		}
	}
61603
public function createFile($fileName)
    {
        foreach ($this->languages() as $languageKey) {
            $file = $this->path."/{$languageKey}/{$fileName}.php";
            if (! $this->disk->exists($file)) {
                file_put_contents($file, "<?php \n\n return[];");
            }
        }
    }