Page 1 of 1

Strange problem

Posted: Sat Aug 01, 2015 9:05 pm
by sdanigo

Hi, I have a database made with appery.
In that database, I store information like :
userID,photo,commentaire.
The photo is a base 64 encoded image.
In my app, I take picture that are stored in that database.

Now, I have to make a copy of these pictures on another system.
So I've made a PHP page that perform a GET on the appery database like that:

code
$url = "https://api.appery.io/rest/1/db/collections/photo&quot
$headers = array(
"Content-Type: application/json",
"X-Appery-Database-Id: myId"
);
$handle = curl_init();
curl_setopt($handle, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($handle, CURLOPT_URL, $url . "?where". urlencode($data_string));
//echo("?where". urlencode($data_string));
//curl_setopt($handle, CURLOPT_URL, $url);
curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);

$data = curl_exec($handle);
curl_close($handle);

//print_r($data);
$array = json_decode($data);

// then I parse my array to extract the image and save them on the other server

/code

For quite all my picture, it works fine , but for some, I have this error (we can see here the end of the photo then some fields following, and particulary the field "commentaire"). At the end, we see the error.

....P86jQHGS5G30GMirMQ3owYKrHpjIP40wuQsJGKnylViOhbOfpUhk2q+4An+HByPpUZLkk5fHQDbkEVEkmzLEZI7dqBBeKskRQqShHOR3rn0VwCOBt985FbjS+YpBjIZjkEHj6VSlhctvBLdjxnNNICjvxgEn+lPUE/Nnj3p7xqGKsQCO2KaiYJG4CgQnbNIWwQAcjFPA+cjPI96SRMHPA9aaA//Z [commentaire] = Mur vers l intérieur [idElement] = 35 [piscineComplete] = [acl] = stdClass Object ( [*] = stdClass Object ( [write] = 1 [read] = 1 ) ) [createdAt] = 2015-07-29 18:55:53.985 [updatedAt] = 2015-07-30 21:14:13.370 ) )

Erreur
Undefined property: stdClass::$commentaire

So I'm quite lost, it works fine for quite all my pictures but for some, it don't and I have this error. Does someone have an idea ?

Thanks

Sylvain


Strange problem

Posted: Sun Aug 02, 2015 3:17 am
by Evgene Karachevtsev

Hello Sylvain,

Could you please look for the differences of these pictures, maybe they have different extensions or sizes?


Strange problem

Posted: Sun Aug 02, 2015 1:47 pm
by sdanigo

Hi. Same extension and different size.


Strange problem

Posted: Mon Aug 03, 2015 11:03 am
by Serhii Kulibaba

Hello Sylvain,

Could you show us full responce from appery.io DB? It looks like your base64 string couldn't be parsed via your php code.


Strange problem

Posted: Mon Aug 03, 2015 9:09 pm
by sdanigo

Hi,
I found the problem, if the field commentaire is empty, it is not transmitted by appery. Is this a bug or do I have something special to setup to transfert all the fields, even the empty one ?


Strange problem

Posted: Tue Aug 04, 2015 11:43 pm
by sdanigo

Hi,
is there any answer for that ?
If I put a value in the field 'commentaire', appery response contain that field and the value.
If I don't appery response doesn't contain the field.
In my opinion it should contains the field with an empty value .

Thanks

Sylvain