code: public function postMedia($call, $filename)
      {
          $this->resetCallState();
  
          $this->call = $call;
  
          $this->method = 'POST';
  
          $this->withMedia = true;
  
          $mimeBoundary = sha1($call . microtime());
  
          $params = array(
              'post' => $this->buildMultipart($mimeBoundary, $filename),
              'headers' => $this->buildUploadMediaHeader($mimeBoundary),
          );
  
          $response = $this->curl->send($this->getUrl(), $params);
  
          $obj = json_decode($response['body']);
  
          if (!$obj || !isset($obj->token_type) || $obj->token_type != 'bearer') {
              $this->findExceptions($response);
          }
  
          $this->headers = $response['headers'];
  
          $this->withMedia = null;
  
          unset($call, $filename, $mimeBoundary, $params, $obj);
  
          return $this->serializer->format($response['body']);
      }
docs: Send a POST call with media upload to Twitter API via OAuth
  
  @param string $call Twitter resource string
  @param string $filename File location to upload
  @return mixed  Output with selected format
  @throws \TwitterOAuth\Exception\CurlException
  @throws \TwitterOAuth\Exception\TwitterException