Skip to content

Commit

Permalink
Post review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
seba-aln committed Jun 18, 2024
1 parent 922b768 commit 1fb3ba8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
21 changes: 11 additions & 10 deletions examples/FileSharing.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,21 @@
$pubnub = new PubNub($config);

// Sending file
// $fileHandle = fopen(__DIR__ . DIRECTORY_SEPARATOR . $fileName, "r");
// $sendFileResult = $pubnub->sendFile()
// ->channel($channelName)
// ->fileName($fileName)
// ->message("Hello from PHP SDK")
// ->fileHandle($fileHandle)
// ->sync();
$fileHandle = fopen(__DIR__ . DIRECTORY_SEPARATOR . $fileName, "r");
$sendFileResult = $pubnub->sendFile()
->channel($channelName)
->fileName($fileName)
->message("Hello from PHP SDK")
->fileHandle($fileHandle)
->sync();

// fclose($fileHandle);
fclose($fileHandle);

// Listing files in the channel
$channelFiles = $pubnub->listFiles()->channel($channelName)->sync();
if ($channelFiles->getCount() > 0) {
print("There are {$channelFiles->getCount()} files in the channel {$channelName}\n");
$fileCount = $channelFiles->getCount();
if ($fileCount > 0) {
print("There are {$fileCount} files in the channel {$channelName}\n");
foreach ($channelFiles->getFiles() as $idx => $file) {
print("File[{$idx}]: {$file->getName()} with ID: {$file->getId()},"
. "size {$file->getSize()}, created at: {$file->getCreationTime()}\n");
Expand Down
4 changes: 2 additions & 2 deletions src/PubNub/Endpoints/FileSharing/PublishFileMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ public function encryptMessage($message)

protected function buildMessage()
{
$message = [
$messageData = [
"message" => $this->message,
"file" => [
"id" => $this->fileId,
"name" => $this->fileName
]
];

return $this->encryptMessage($message);
return $this->encryptMessage($messageData);
}

protected function customParams()
Expand Down
6 changes: 3 additions & 3 deletions src/PubNub/Endpoints/FileSharing/SendFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,13 @@ public function sync()
if (isset($this->meta)) {
$publishRequest->meta($this->meta);
}
if (isset($this->meta)) {
if (isset($this->message)) {
$publishRequest->message($this->message);
}
if (isset($this->meta)) {
if (isset($this->shouldStore)) {
$publishRequest->shouldStore($this->shouldStore);
}
if (isset($this->meta)) {
if (isset($this->ttl)) {
$publishRequest->ttl($this->ttl);
}

Expand Down

0 comments on commit 1fb3ba8

Please sign in to comment.