/** * Upload material. * * @param string $type * @param string $path * @param array $form * * @return string * * @throws InvalidArgumentException */ protected function uploadMedia($type, $path, array $form = []) { if (!file_exists($path) || !is_readable($path)) { throw new InvalidArgumentException("File does not exist, or the file is unreadable: '{$path}'"); } $form = array_merge($form, ['type' => $type]); return $this->http->upload($this->getApi($type), ['media' => $path], $form); }
/** * Upload temporary material. * * @param string $type * @param string $path * * @return string * * @throws InvalidArgumentException */ public function upload($type, $path) { if (!file_exists($path) || !is_readable($path)) { throw new InvalidArgumentException("File does not exist, or the file is unreadable: '{$path}'"); } if (!in_array($type, $this->allowTypes, true)) { throw new InvalidArgumentException("Unsupported media type: '{$type}'"); } return $this->http->upload(self::API_UPLOAD, ['media' => $path]); }
/** * Set staff avatar. * * @param string $email * @param string $path * * @return bool */ public function avatar($email, $path) { return $this->http->upload(self::API_AVATAR_UPLOAD, ['media' => $path], ['kf_account' => $email]); }