질문은 어떻게하면 내 파일 시스템에 새 폴더를 만들 수 있습니까? 파일을 추가하는 방법을 알고 있지만 지정된 경로에 빈 폴더를 만드는 방법은 알고 있습니까?Symfony2 Gaufrette 디렉토리를 만드는 방법은 무엇입니까?
2
A
답변
0
그런 다음 write
apapter라는 디렉터리에 있는지 확인하십시오. 예를 들어 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)
{
...
}
3
나는 아마존 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/", "");
0
단순히 Local
어댑터에 true
전달 :
use Gaufrette\Adapter\Local as LocalAdapter;
...
$adapter = new LocalAdapter(__DIR__ . '/your-new-dir', true);
$filesystem = new Filesystem($adapter);
솔루션은 Google Cloud Storage에서도 작동합니다. – Alex