-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix getMetadata() to have data for S3 folders
- Loading branch information
1 parent
a28a3cc
commit 3fc87d0
Showing
3 changed files
with
40 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace CloudFiles\Adapter; | ||
|
||
use ExpressionEngine\Dependency\League\Flysystem; | ||
|
||
abstract class AbstractS3 extends Flysystem\AwsS3v3\AwsS3Adapter | ||
{ | ||
|
||
/** | ||
* Get all the meta data of a file or directory. | ||
* | ||
* @param string $path | ||
* | ||
* @return false|array | ||
*/ | ||
public function getMetadata($path) | ||
{ | ||
$metadata = parent::getMetadata($path); | ||
|
||
if ($metadata !== false) { | ||
return $metadata; | ||
} | ||
|
||
// AWS looks for metadata with a headObject request, this returns 404 (false) on directories | ||
if (!empty($this->listContents($path))) { | ||
return ['type' => 'dir', 'path' => $path, 'size' => 0, 'timestamp' => null]; | ||
} | ||
|
||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters