Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add peek option into Attachment
  • Loading branch information
artem-stepanov committed Oct 26, 2016
commit ed990d96e30cc987b3d315a2d12232e233afe94c
8 changes: 4 additions & 4 deletions src/Fetch/Attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ public function getData()
{
if (!isset($this->data)) {
$messageBody = isset($this->partId) ?
imap_fetchbody($this->imapStream, $this->messageId, $this->partId, FT_UID)
: imap_body($this->imapStream, $this->messageId, FT_UID);
imap_fetchbody($this->imapStream, $this->messageId, $this->partId, FT_UID | FT_PEEK)
: imap_body($this->imapStream, $this->messageId, FT_UID | FT_PEEK);

$messageBody = Message::decode($messageBody, $this->encoding);
$this->data = $messageBody;
Expand Down Expand Up @@ -220,8 +220,8 @@ public function saveAs($path)

// Fix an issue causing server to throw an error
// See: https://github.com/tedious/Fetch/issues/74 for more details
$fetch = imap_fetchbody($this->imapStream, $this->messageId, $this->partId ?: 1, FT_UID);
$result = imap_savebody($this->imapStream, $filePointer, $this->messageId, $this->partId ?: 1, FT_UID);
$fetch = imap_fetchbody($this->imapStream, $this->messageId, $this->partId ?: 1, FT_UID | FT_PEEK);
$result = imap_savebody($this->imapStream, $filePointer, $this->messageId, $this->partId ?: 1, FT_UID | FT_PEEK);

if ($streamFilter) {
stream_filter_remove($streamFilter);
Expand Down