-
Notifications
You must be signed in to change notification settings - Fork 355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added stream feature to AwsS3 adapter. #334
Open
jskarpe
wants to merge
1
commit into
KnpLabs:master
Choose a base branch
from
jskarpe:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,107 @@ | ||
<?php | ||
namespace Gaufrette\Stream; | ||
|
||
use Gaufrette\Stream; | ||
use Gaufrette\StreamMode; | ||
|
||
/** | ||
* Http stream. | ||
* Similar to Local stream, but the HTTP protocol | ||
* does not allow simultaneous reading and writing. | ||
* | ||
* @author Jon Skarpeteig <[email protected]> | ||
*/ | ||
class Http extends Local implements Stream | ||
{ | ||
|
||
protected $context; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param string $path | ||
*/ | ||
public function __construct($path, $context = null) | ||
{ | ||
$this->context = ($context === null) ? stream_context_create() : $context; | ||
$this->path = $path; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function open(StreamMode $mode) | ||
{ | ||
if ($mode->allowsRead() && $mode->allowsWrite()) { | ||
throw new \RuntimeException(sprintf('File "%s" cannot be opened with read and write mode simultaneously', $this->path)); | ||
} | ||
|
||
try { | ||
$fileHandle = @fopen($this->path, $mode->getMode(), false, $this->context); | ||
} catch (\Exception $e) { | ||
$fileHandle = false; | ||
} | ||
|
||
if (false === $fileHandle) { | ||
throw new \RuntimeException(sprintf('File "%s" cannot be opened', $this->path)); | ||
} | ||
|
||
$this->mode = $mode; | ||
$this->fileHandle = $fileHandle; | ||
|
||
return true; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function stat() | ||
{ | ||
if ($this->fileHandle) { | ||
|
||
/** | ||
* 0 dev device number | ||
* 1 ino inode number * | ||
* 2 mode inode protection mode | ||
* 3 nlink number of links | ||
* 4 uid userid of owner * | ||
* 5 gid groupid of owner * | ||
* 6 rdev device type, if inode device | ||
* 7 size size in bytes | ||
* 8 atime time of last access (Unix timestamp) | ||
* 9 mtime time of last modification (Unix timestamp) | ||
* 10 ctime time of last inode change (Unix timestamp) | ||
* 11 blksize blocksize of filesystem IO ** | ||
* 12 blocks number of 512-byte blocks allocated ** | ||
* On Windows this will always be 0. | ||
* * Only valid on systems supporting the st_blksize type - other systems (e.g. Windows) return -1. | ||
*/ | ||
|
||
/** | ||
* Directories must be a mode like 040777 (octal), and files a mode like 0100666. | ||
* | ||
* If you wish the file to be executable, use 7s instead of 6s. The last 3 digits | ||
* are exactly the same thing as what you pass to chmod. 040000 defines a directory, | ||
* and 0100000 defines a file. | ||
*/ | ||
|
||
return array( | ||
'dev' => 0, | ||
'ino' => 0, | ||
'mode' => 0100666, | ||
'nlink' => 0, | ||
'uid' => 0, | ||
'gid' => 0, | ||
'rdev ' => 0, | ||
'size' => filesize($this->path), | ||
'atime' => 0, | ||
'mtime' => filemtime($this->path), | ||
'ctime' => 0, | ||
'blksize' => - 1, | ||
'blocks' => - 1 | ||
); | ||
} | ||
|
||
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks wrong to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making things protected means they become extension points which need to be taken into account for backward compatibility. And extension points by inheritance are the worse ones regarding BC layers (we implement BC layers in Symfony since years, and the ones involving inheritance and BC for protected things have always been the worse ones to implement)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So what's the fix? Copy everything over?
On Sun, Sep 20, 2015 at 8:32 AM, Christophe Coevoet <
[email protected]> wrote: