Hello,
Adding the support for add.Simple
http://piwigo.org/doc/doku.php?id=en:de … .addsimple
for Jiwigo (and ultimately for ReGalAndroid...); I have the following response after sending my request :
Notice: Undefined index: image in /home/sys/var/www/piwigo_master_21/plugins/pwg_images_addSimple/main.inc.php on line 97
Notice: Undefined index: image in /home/sys/var/www/piwigo_master_21/plugins/pwg_images_addSimple/main.inc.php on line 98
Warning: getimagesize(././uploads/y/c/a/ycajh4petv/2011/04/18/20110418050817-.jpg) [<a href='function.getimagesize'>function.getimagesize</a>]: failed to open stream: No such file or directory in /home/sys/var/www/piwigo_master_21/admin/include/functions_upload.inc.php on line 186
Warning: getimagesize(././uploads/y/c/a/ycajh4petv/2011/04/18/20110418050817-.jpg) [<a href='function.getimagesize'>function.getimagesize</a>]: failed to open stream: No such file or directory in /home/sys/var/www/piwigo_master_21/admin/include/functions_upload.inc.php on line 288
Warning: filesize() [<a href='function.filesize'>function.filesize</a>]: stat failed for ././uploads/y/c/a/ycajh4petv/2011/04/18/20110418050817-.jpg in /home/sys/var/www/piwigo_master_21/admin/include/functions_upload.inc.php on line 289
Warning: imagecreatefromjpeg(././uploads/y/c/a/ycajh4petv/2011/04/18/20110418050817-.jpg) [<a href='function.imagecreatefromjpeg'>function.imagecreatefromjpeg</a>]: failed to open stream: No such file or directory in /home/sys/var/www/piwigo_master_21/admin/include/functions_upload.inc.php on line 215
Warning: imagesx(): supplied argument is not a valid Image resource in /home/sys/var/www/piwigo_master_21/admin/include/functions_upload.inc.php on line 227
Warning: imagesy(): supplied argument is not a valid Image resource in /home/sys/var/www/piwigo_master_21/admin/include/functions_upload.inc.php on line 228
Warning: copy(././uploads/y/c/a/ycajh4petv/2011/04/18/20110418050817-.jpg) [<a href='function.copy'>function.copy</a>]: failed to open stream: No such file or directory in /home/sys/var/www/piwigo_master_21/admin/include/functions_upload.inc.php on line 250
Warning: getimagesize(././uploads/y/c/a/ycajh4petv/2011/04/18/thumbnail/TN-20110418050817-.jpg) [<a href='function.getimagesize'>function.getimagesize</a>]: failed to open stream: No such file or directory in /home/sys/var/www/piwigo_master_21/admin/include/functions_upload.inc.php on line 288
Warning: filesize() [<a href='function.filesize'>function.filesize</a>]: stat failed for ././uploads/y/c/a/ycajh4petv/2011/04/18/thumbnail/TN-20110418050817-.jpg in /home/sys/var/www/piwigo_master_21/admin/include/functions_upload.inc.php on line 289
Warning: filesize() [<a href='function.filesize'>function.filesize</a>]: stat failed for ././uploads/y/c/a/ycajh4petv/2011/04/18/20110418050817-.jpg in /home/sys/var/www/piwigo_master_21/admin/include/functions_metadata.php on line 137
<?xml version="1.0" encoding="utf-8" ?>
<rsp stat="ok">
<image_id>116</image_id><url>http://mael.piwigo.com/picture?/116/category/98-categoryaddsimpletest</url>
</rsp>
The HTTP status code was 200; confirmed by rsp ok status; not that good for a failure...
In the HTTP request, I gave the following elements, as part of an multipart/form-data :
method : pwg.images.addSimple
category : 98
name : title1303094948758
and then , in octet-stream :
Content-Disposition: form-data; name="file"; filename="piwigo_org.png"
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
You can have a look at the result in the gallery :
http://mael.piwigo.com/index?/category/ … simpletest
you'll see pictures entries, but without any picture available...
The problem occurred during processing of add.Simple
Thank you for your help,
Anthony
Hors ligne
Bobjour.
Quelle Version piwigo ?
Hors ligne
Obviously, you're on Piwigo.com (so currently this is Piwigo 2.1 but that's not the problem)
The problem is that the photo is not correctly received by Piwigo.
Did you correctly post your form with Content-Type as multipart/form-data ?
Hors ligne
oui, multipart/form-data.
voici la requete, telle que vu par Wireshark :
POST /ws.php HTTP/1.1
Content-Length: 7749
Content-Type: multipart/form-data; boundary=E2-8W4Ub3YcIKIATvWI1j5kmizQ4rvefUcw2FmY
Host: mael.piwigo.com
Connection: Keep-Alive
User-Agent: Unit Test
Cookie: pwg_id=754d9a1eda1c40c1781f5e7f5a1d416d
Cookie2: $Version=1
--E2-8W4Ub3YcIKIATvWI1j5kmizQ4rvefUcw2FmY
Content-Disposition: form-data; name="method"
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit
pwg.images.addSimple
--E2-8W4Ub3YcIKIATvWI1j5kmizQ4rvefUcw2FmY
Content-Disposition: form-data; name="category"
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit
98
--E2-8W4Ub3YcIKIATvWI1j5kmizQ4rvefUcw2FmY
Content-Disposition: form-data; name="name"
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit
title1303094948758
--E2-8W4Ub3YcIKIATvWI1j5kmizQ4rvefUcw2FmY
Content-Disposition: form-data; name="file"; filename="piwigo_org.png"
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
PNG
IHDRPSYtEXtSoftwareAdobe ImageReadyqe<fiTXtXML:com.adobe.xmp<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?> <x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.0-c060 61.134777, 2010/02/12-17:32:00 "> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:Description rdf:about="" xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/" xmlns:stRef="http://ns.adobe.com/xap/1.0/sType/ResourceRef#" xmlns:xmp="http://ns.adobe.com/xap/1.0/" xmpMM:OriginalDocumentID="xmp.did:149AEBB0D6F1DF11ABBBF804753EF909" xmpMM:DocumentID="xmp.did:DCA48E6A0C4A11E0BCBC8E12071017CF" xmpMM:InstanceID="xmp.iid:DCA48E690C4A11E0BCBC8E12071017CF" xmp:CreatorTool="Adobe Photoshop CS5 Macintosh"> <xmpMM:DerivedFrom stRef:instanceID="xmp.iid:C9836C660F206811AB088836DC3525E2" stRef:documentID="xmp.did:149AEBB0D6F1DF11ABBBF804753EF909"/> </rdf:Description> </rdf:RDF> </x:xmpmeta> <?xpacket end="r"?>X0m]IDATx]XU_"(>L=^'')snMgJS7yS0,doiNuFOS #(tq~qug9sZko3w$5G &<At3&XRHn-T3lOY{]ehiGaB;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)''9&c\%t7@Rl60Jy`frkmOCe\nt%n7?/vZL99zOuULRHB#BBBBBBBM/jVtIENDB`
--E2-8W4Ub3YcIKIATvWI1j5kmizQ4rvefUcw2FmY--
Hors ligne
Je n'arrive pas à obtenir le même type de sortie que toi sur wireshark (première fois que je l'utilise) mais sur une requêtes HTTP avec la méthode pwg.images.addSimple, j'ai plutôt du:
Content-Type: multipart/form-data
(et ça passe bien)
Hors ligne
ah non pardon, tu as ça aussi pour le Content-Type de la requête (je regardais le Content-Type de la variable "method")
Hors ligne
ok merci plg.
Pourrais tu, s'il te plait, joindre ton POST vu par wireshark (il faut faire 2 export as writable text; 1 pour le post, et 'autre pour le multi part, si je me souvbiens bien)
Comme çà on pourra comparer et voir ce qui fait que ca marche pas dans mon code.
Ou sinon, donne moi l'url et la categorie d'une de tes galleries, comme ca tu pourras voir ce que ca fait (mon code)
Dans un second temps, je pense, en tant que consommateur de l'api ws de Piwigo, qu'il faudrait revnoyer un code d'erreur et non pas 200 lorsqu'une erreur survient; un consommateur part du principe que ca s'est bien passé si la reponse est 200...
Merci beaucoup pour ton temps
Cordialement,
Anthony
Hors ligne
Je pense que ça va être compliqué si on compare des dump de versions différentes de wireshark et que ça risque de prendre du temps pour la comparaison...
En espérant que tu es sous Linux, je te propose de faire tourner ce petit script Perl qui fonctionne:
#!/usr/bin/perl use LWP::UserAgent; my %conf = ( base_url => 'http://mael.piwigo.com', username => 'mael', password => 'HxvDKTM3kGc', image_path => '/tmp/piwigo_on_dreamhost.png', category => 98 ); my $ua = LWP::UserAgent->new; $ua->cookie_jar({}); $ua->post( $conf{base_url}.'/ws.php', { method => 'pwg.session.login', username => $conf{username}, password => $conf{password}, } ); $ua->post( $conf{base_url}.'/ws.php', { method => 'pwg.images.addSimple', image => [$conf{image_path}], category => $conf{category}, }, 'Content_Type' => 'form-data', );
Il faut changer le mot de passe et le chemin pour l'image bien sûr. Tu sauvegardes ça dans un fichier /tmp/piwigo_addSimple.pl par exemple, et tu le lances avec :
perl /tmp/piwigo_addSimple.pl
A partir du moment où tu arriveras à faire tourner ça sur ta machine, tu auras un point de comparaison fiable pour reproduire la même chose avec Java. Ca te va comme procédure ?
Note : sous Ubuntu, pour avoir le module Perl LWP::UserAgent il faut :
apt-get install libwww-perl
Hors ligne
ah ben là.... mea culpa.
J'ai essay'e avec ton script en perl, et pis ca amarchait, et pis j ai vu que le nom du champ qui porte le fichier (multipart) doit s'appeler image... et moi j avais mis file...
Bon, merci pour ton aide plg; maintenant mon client pour addSimple fonctionne...
Reste que, si addSimple pouvait reporter les requetes en erreur.. ca aiderait les etourdis comme moi !
Abon entendeur !
Merci encore !
Hors ligne