问题是如何在我的文件系统中创建新文件夹?我知道如何添加文件,但是如何在指定路径中创建一个空文件夹?
问问题
3195 次
3 回答
3
我正在使用 Amazon S3 适配器,并且能够使用以下内容创建目录:
use Gaufrette\Filesystem;
use Gaufrette\Adapter\AwsS3;
use Aws\S3\S3Client;
$s3Service = S3Client::factory(array("key" => "Your Key Here", "secret" => "Your AWS Secret Here" ));
$adapter = new AwsS3($s3Service,"yourBucketNameHere");
$filesystem = new Filesystem($adapter);
$filesystem->write("new-directory-here/", "");
于 2014-07-03T00:48:38.990 回答
0
然后调用write
aapter 确保该目录存在。例如ftp
public function write($key, $content)
{
$this->ensureDirectoryExists($this->directory, $this->create);
$path = $this->computePath($key);
$directory = dirname($path);
$this->ensureDirectoryExists($directory, true);
...
}
/**
* Ensures the specified directory exists. If it does not, and the create
* parameter is set to TRUE, it tries to create it
*/
protected function ensureDirectoryExists($directory, $create = false)
{
...
}
于 2014-01-21T15:37:49.020 回答
0
只需传递true
给Local
适配器:
use Gaufrette\Adapter\Local as LocalAdapter;
...
$adapter = new LocalAdapter(__DIR__ . '/your-new-dir', true);
$filesystem = new Filesystem($adapter);
于 2016-08-30T11:46:12.070 回答