Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cweagans/4040d261c18c286c5b3e8c0cf46ae94f to your computer and use it in GitHub Desktop.
Save cweagans/4040d261c18c286c5b3e8c0cf46ae94f to your computer and use it in GitHub Desktop.
Fix uploading files to Twitter when they originate from an S3 bucket
diff --git a/src/TwitterOAuth.php b/src/TwitterOAuth.php
index 37114c5..4988dbb 100644
--- a/src/TwitterOAuth.php
+++ b/src/TwitterOAuth.php
@@ -330,21 +330,20 @@ class TwitterOAuth extends Config
* Private method to upload media (not chunked) to upload.twitter.com.
*
* @param string $path
* @param array $parameters
*
* @return array|object
*/
private function uploadMediaNotChunked(string $path, array $parameters)
{
if (
- !is_readable($parameters['media']) ||
($file = file_get_contents($parameters['media'])) === false
) {
throw new \InvalidArgumentException(
'You must supply a readable file',
);
}
$parameters['media'] = base64_encode($file);
return $this->http(
'POST',
self::UPLOAD_HOST,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment