diff --git a/src/Iloveimg.php b/src/Iloveimg.php index ce2f295..a476179 100644 --- a/src/Iloveimg.php +++ b/src/Iloveimg.php @@ -34,7 +34,7 @@ class Iloveimg // @var string|null The version of the Iloveimg API to use for requests. public static $apiVersion = 'v1'; - const VERSION = 'php.1.0.2'; + const VERSION = 'php.1.1.16'; public $token = null; @@ -187,6 +187,9 @@ public function sendRequest($method, $endpoint, $body = null, $start = false) throw new AuthException($response->body->name, $response->code, null, $response); } if ($endpoint == 'upload') { + if(is_string($response->body)){ + throw new UploadException("Upload error", $response->code, null, $response); + } throw new UploadException($response->body->error->message, $response->code, null, $response); } elseif ($endpoint == 'process') { throw new ProcessException($response->body->error->message, $response->code, null, $response); diff --git a/src/ImageTask.php b/src/ImageTask.php index cbc4fc8..548fc5a 100644 --- a/src/ImageTask.php +++ b/src/ImageTask.php @@ -179,6 +179,10 @@ public function addFileFromUrl($url) */ public function uploadFile($task, $filepath) { + if(!file_exists($filepath)){ + throw new \InvalidArgumentException('File '.$filepath.' does not exists'); + } + $data = array('task' => $task, 'v' => self::VERSION); $files = array('file' => $filepath); $body = Request\Body::multipart($data, $files);