Salut à tous,
J'ai fais un webservice en java with jersey qui upload des vidéos. Dans mes tests unitaire je n'ai aucun soucis. En revanche sur mon client php 5 with curl, lorsque j'appel mon web service j'ai un problème de path.
Mon web service doit me renvoyer le chemin où le fichier à été upload (ici /home/user/nom_fichier). En revanche dans mon test unitaire sur mon client php 5 le message de retour est /home/user//home/user/test/fichier.avi.
Comme si php 5 n'arrive pas à récupérer juste le nom du fichier et m'affiche directement le path du fichier à la place du nom du fichier.
Voici le code du client php :
Code php du test unitaire :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 public function fileUpload($url, $pathVideo){ $params = array('name' => 'file', 'file' => '@' . $pathVideo); $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl, CURLOPT_INFILESIZE, -1); curl_setopt($curl, CURLOPT_TIMEOUT, 60); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $params); curl_setopt($curl, CURLOPT_USERPWD, $this->apikey .':'. $this->apisecret); $response = curl_exec($curl); $status = curl_getinfo($curl, CURLINFO_HTTP_CODE); curl_close($curl); return $response; }
Merci d'avance.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 public function testFileUpload(){ $client = new ClientPhpWS('test', 'test'); $url = 'http://localhost:8080/project/test/fileupload'; $pathVideo = '/home/user/test/fichier.avi'; $this->assertEquals("File uploaded to : /home/user/fichier.avi", $client->fileUpload($url, $pathVideo)); }
John.





Répondre avec citation

Partager