Start a new topic
Answered

Multi delete possible?

Hello 


I wonder if it's possible to delete several files in one step. The REST API shows an example to delete a file by _id, that is of course unique. In wonder if it is possible to delete more than one file in a single step by querying another column than _id? Example:


I have two files:

_id       group   ... 

ABC    AAA

DEF    AAA


Is it possible to delete a file by the mentioned custom filed 'group'? Both files belong to that group, so both would then be deleted in one step. Or is the delete operation only possible by the _id of a file?


Regards



Best Answer

Tayger,


Using this method, you can delete only one file at a time.


Please try making a DELETE request on "/appdata/<your kid>/_blob/?query={"group":"AAA"}". I think this should delete all the entities whose 'group" value is "AAA". Let me know if it works.


Thanks,

Pranav

Kinvey


Answer

Tayger,


Using this method, you can delete only one file at a time.


Please try making a DELETE request on "/appdata/<your kid>/_blob/?query={"group":"AAA"}". I think this should delete all the entities whose 'group" value is "AAA". Let me know if it works.


Thanks,

Pranav

Kinvey

Hello again


Sorry for my too quick answer! I was not aware of your different link! After re-reading I saw the difference! I have tried your path-link and the group deletion works as QUERY!

Excellent, thank you!

Regards


Hello Pranav


I'm using the DELETE operation on collections and it works with a QUERY (mutli-delete). Thats ok... But it doesn't seem to work on the files:  

// curl_setopt ($ch, CURLOPT_URL, 'https://baas.kinvey.com/blob/kid_xxxxxxx/'. $filelist[$f] .'?tls=true'); // -> This one is working fine!
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, 'https://baas.kinvey.com/blob/kid_xxxxxxx?query={"gameid":"'.$publicid.'"}'); // Leads to error (see below)
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
curl_setopt ($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json","Authorization: Kinvey ".$authtoken, "X-Kinvey-API-Version: 3" ));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$return =json_encode( curl_exec ($ch), true);
print_r ($return);                
curl_close ($ch);

  DELETE by _ID works fine on files. As soon as I use the QUERY option on files I got this message:


"{\"error\":\"The request was not understood.\",\"request\":\"DELETE \/blob\/kid_SkYzM4SHM\/?query={\\\"gameid\\\":\\\"GN6XVRB\\\"}\"}""{\"error\":\"The request was not understood.\",\"request\":\"DELETE \/blob\/kid_SkYzM4SHM\/?query={\\\"gameid\\\":\\\"GN6XVRB\\\"}\"}


The code sample above is set to produce this error while there is a remarked line with which the DELETE (on _ID) works fine.

It's not a big issue to me since I can delete by _ID. I thought this might my a security issue by Kinvey not allowing Query-Delete.


Regards

Login or Signup to post a comment