Created
April 26, 2024 08:17
-
-
Save cweagans/4040d261c18c286c5b3e8c0cf46ae94f to your computer and use it in GitHub Desktop.
Fix uploading files to Twitter when they originate from an S3 bucket
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
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