Skip to content

Instantly share code, notes, and snippets.

@vgdub
Last active September 15, 2015 18:40
Show Gist options
  • Save vgdub/2d4fa35e630f6c332cc3 to your computer and use it in GitHub Desktop.
Save vgdub/2d4fa35e630f6c332cc3 to your computer and use it in GitHub Desktop.

Revisions

  1. vgdub revised this gist Sep 15, 2015. No changes.
  2. vgdub revised this gist Sep 15, 2015. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions FPError.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    FP Error: Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: not found (404)" UserInfo=0x7fa15e4bc490 {NSUnderlyingError=0x7fa15e440a00 "Request failed: unacceptable content-type: text/html", com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x7fa1608c00a0> { URL: https://dialog.filepicker.io/api/pathhttps%3A%2F%2Fmatchup-io-dev.s3.amazonaws.com%2Fuploads%2Fusers%2F2015-09-14%2F10103881160450198.jpg } { status code: 404, headers {
    "Content-Encoding" = gzip;
    "Content-Type" = "text/html; charset=utf-8";
    Date = "Mon, 14 Sep 2015 23:30:01 GMT";
    Server = nginx;
    "Set-Cookie" = "session=\"Q0agqTmnI5EUlhFWI3l3kEPa9gk=?_expires=STE0NDQ5NTE4MDEKLg==&_fresh=STAwCi4=&_id=UyckXHgwZlx4Y2ZceDkzXHg5Mlx4ZjVceDBjXHg5Zlx4OWMsXHhkMXk0XHhjN1x4OWJceGZhJwpwMQou&_permanent=STAxCi4=&cmux_rd=Ti4=&facebook_request_token=UydlbXB0eScKcDEKLg==&recent_path=Vi9GYWNlYm9vay90YWdnZWQvCnAxCi4=&user_auth_id=STQ2MTMyMjIKLg==\"; Domain=dialog.filepicker.io; expires=Thu, 15-Oct-2015 23:30:01 GMT; Path=/; HttpOnly";
    "Transfer-Encoding" = Identity;
    } }, NSErrorFailingURLKey=https://dialog.filepicker.io/api/pathhttps%3A%2F%2Fmatchup-io-dev.s3.amazonaws.com%2Fuploads%2Fusers%2F2015-09-14%2F10103881160450198.jpg, com.alamofire.serialization.response.error.data=<.....>, NSLocalizedDescription=Request failed: not found (404)}
  3. vgdub revised this gist Sep 15, 2015. 1 changed file with 20 additions and 5 deletions.
    25 changes: 20 additions & 5 deletions filepickerExample.swift
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,30 @@
    func selectAvatar(sender: XLFormRowDescriptor){
    let fpController:FPPickerController = FPPickerController()
    fpController.fpdelegate = self
    fpController.dataTypes = ["image/*"]
    fpController.sourceNames = NSArray(objects: FPSourceCamera, FPSourceCameraRoll, FPSourceFacebook, FPSourceInstagram, FPSourceImagesearch) as [AnyObject]
    fpController.allowsEditing = true
    fpController.modalPresentationStyle = UIModalPresentationStyle.Popover

    self.fpSave = FPSaveController()
    self.fpSave.fpdelegate = self
    self.fpSave.dataType = "image/*"

    let presentationController:UIPopoverPresentationController = fpController.popoverPresentationController!
    presentationController.permittedArrowDirections = UIPopoverArrowDirection.Any

    self.presentViewController(fpController, animated: true, completion: nil)
    }


    func fpPickerController(pickerController: FPPickerController!, didFinishPickingMediaWithInfo info: FPMediaInfo!) {
    NSLog("File Chosen: %@", info)
    if info != nil {
    if info.containsImageAtMediaURL() {
    let image:UIImage = UIImage(contentsOfFile: info.mediaURL.path!)!
    self.displayedImages.removeAllObjects()
    self.displayedImages.addObject(image)
    self.selectedImageInfo = info

    let imgData:NSData = UIImagePNGRepresentation(image)
    self.fpSave.data = imgData

    self.fpSave.data = imgData
    self.fpSave.proposedFilename = info.key
    self.fpSave.saveFileName(info.filename, to: "https://\(S3_BUCKET_NAME).s3.amazonaws.com/uploads/users/2015-09-14/")
    }
  4. vgdub created this gist Sep 15, 2015.
    20 changes: 20 additions & 0 deletions filepickerExample.swift
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    func fpPickerController(pickerController: FPPickerController!, didFinishPickingMediaWithInfo info: FPMediaInfo!) {
    NSLog("File Chosen: %@", info)
    if info != nil {
    if info.containsImageAtMediaURL() {
    let image:UIImage = UIImage(contentsOfFile: info.mediaURL.path!)!
    self.displayedImages.removeAllObjects()
    self.displayedImages.addObject(image)
    self.selectedImageInfo = info

    let imgData:NSData = UIImagePNGRepresentation(image)
    self.fpSave.data = imgData

    self.fpSave.proposedFilename = info.key
    self.fpSave.saveFileName(info.filename, to: "https://\(S3_BUCKET_NAME).s3.amazonaws.com/uploads/users/2015-09-14/")
    }
    self.dismissViewControllerAnimated(true, completion: nil)
    } else {
    NSLog("Nothing Picked")
    }
    }