title: how to upload recorded audio file to parse?
body: <p>Posted my code <a href="http://pastebin.com/d8PM8u1B#" rel="nofollow">here, was getting clipped below</a>.</p>
  
  <p>As per the code above, I am creating an audio file called <code>sound.caf</code> at a known filepath location <code>soundfileURL</code>. </p>
  
  <p>My question is how can I upload this file to Parse? How to get the file object in the code from the path <code>soundfileURL</code>.</p>
  
  <p>My attempt below, needs work obviously. I haven't run it because i dont know how to convert <code>sound.caf</code> to PFFile and upload to Parse.</p>
  
  <pre><code>func addNamestoParse(obj: Music) {
      println("Doing Parse Stuff now")
      self.showActivityIndicatory(true)
  
      var className = PFObject(className: "musicrecording")
      className.setObject(obj.name, forKey: "nameofmusic")
      className.setObject(obj.createdOn, forKey: "datcreated")
  </code></pre>
  
  <p><strong>HOW TO CONVERT SOUND.CAF FILE TO PFFILE HERE &amp; UPLOAD TO PARSE??</strong></p>
  
  <pre><code>    className.saveInBackgroundWithBlock {
          (success: Bool, error: NSError?) -&gt; Void in
  
          if success == true {
  
  
  
          } else {
  
              println(error)
  
          }
      }
  
  }
  </code></pre>
  
  <p>Thanks to <strong>David Jirman</strong> for the Objective-C equivalent was able to deduce the Swift Equivalent. Below is the code.</p>
  
  <pre><code>func addNamestoParse(obj: Name) {
      println("Doing Parse Stuff now")
  
      var className = PFObject(className: "namerecordings")
      className.setObject(obj.name, forKey: "babyname")
      className.setObject(obj.nameSubmitter, forKey: "submittedby")
      className.saveInBackgroundWithBlock {
          (success: Bool, error: NSError?) -&gt; Void in
  
          if success == true {
              let audioFile = PFFile(name: "mysound.caf", data: NSData(contentsOfURL: self.soundFileURL)!)
              className["audioFile"] = audioFile
  
              className.saveInBackgroundWithBlock{(success: Bool, error: NSError?) -&gt; Void in
  
                  if success == false {
                      println("error in uploading audio file")
                  } else {
                      println("posted successfully")
  
                  }
              }
  
          } else {
  
              println(error)
  
          }
      }
  
  }
  </code></pre>