Skip to content

Commit

Permalink
Cast Multipart Contents to String.
Browse files Browse the repository at this point in the history
  • Loading branch information
irazasyed committed Jul 12, 2015
1 parent 51e837a commit 5a2e743
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Telegram.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Telegram
/**
* @const string Version number of the Telegram Bot PHP SDK.
*/
const VERSION = '0.2.2';
const VERSION = '0.2.3';

/**
* @const string The name of the environment variable that contains the Telegram Bot API Access Token.
Expand Down Expand Up @@ -565,10 +565,16 @@ public function uploadFile($endpoint, array $params = [])
$i = 0;
$multipart_params = [];
foreach ($params as $name => $contents) {
if (is_null($contents)) {
continue;
}

if (is_file($contents)) {
$file = new InputFile($contents);
$contents = $file->open();
$contents = (new InputFile($contents))->open();
} else {
$contents = (string) $contents;
}

$multipart_params[$i]['name'] = $name;
$multipart_params[$i]['contents'] = $contents;
++$i;
Expand Down

0 comments on commit 5a2e743

Please sign in to comment.