title: Parse.com - Host private files and conditionally allow download
body: <p>I want to host several levels for my game in parse cloud and on certain conditions.</p>
  
  <p><s>First of all how to download files which theoritically can be accessed by any user?</s></p>
  
  <p><strong>Update:</strong> Ok, I've created a custom class and put a column with a File type and uploaded my files.</p>
  
  <p>Secondly how to create an API which will check certain conditions for particular user and if they are met then allow and start downloading?</p>
  
  <p><strong>Edit (more info):</strong> Let's say I have a button to download some files. When users presses it, I want Parse to check some conditions in Cloud Code and if they are met then it will start download, or else will tell user it is not possible yet.</p>
  
  <p><strong>Edit2:</strong> Seems like I got banned from asking for this question, but I dont know how to make it more clear. Actually, I already found the way. So here is the answer I was seeking around, now you can see I expressed myself right.</p>
  
  <p>What I did is wrote the simple function in cloud code which looks like this: </p>
  
  <pre><code>Parse.Cloud.define("check", function(request, response) {
     var user = Parse.User.current();//request.user;
  
     if (user != null) {
     var field1 = user.get("field1");
     var field2 = user.get("field2");
                     console.log(field1);
                     console.log(field2);
     response.success(field1 &lt; field2);
     } else {
     response.error("user isn't logged in");
     }
  });
  </code></pre>
  
  <p>Then in my app I just do the following : </p>
  
  <pre><code> if let cloudCheck = PFCloud.callFunction("check", withParameters: nil) as? Bool {
                  //download files if cloudCheck is true
              }
  </code></pre>