Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Including base-64-encoded image in json body of a .POST triggering crash every time in Xcode 6.4 #738

Closed
ghost opened this issue Sep 4, 2015 · 3 comments

Comments

@ghost
Copy link

ghost commented Sep 4, 2015

Added notes:

  • the image is optional; users generated without image is fine
  • breakpoint verified data is not nil

Code:

var params: [String : AnyObject] = [:]
params["email"] = email
params["password"] = password
params["first_name"] = firstName
params["last_name"] = lastName

// Including a base 64 encoded image is triggering a crash in xcode 6.4
if let image = avatar {
    var imageData = UIImagePNGRepresentation(image).base64EncodedDataWithOptions(
        .Encoding64CharacterLineLength
    )
    params["image"] = imageData
}

Alamofire.request(.POST, request, parameters: params, encoding: .JSON, headers: self.defaultHeaders())
    .response { request, response, data, error in
         print(error)
    }
@ghost ghost changed the title Including base-64-encoded image in json body of a .POST triggering crash every time on Xcode Including base-64-encoded image in json body of a .POST triggering crash every time in Xcode 6.4 Sep 4, 2015
@cnoon
Copy link
Member

cnoon commented Sep 6, 2015

Hi @genu1,

I just added tests around this behavior in 33dcfd4 demonstrating how to do this. I'm not exactly sure why you are crashing, but Alamofire can handle this case without issue. I'm going to close this issue out for now. If you provide more info that leads us to believe there is an issue in Alamofire, we'll be happy to re-open.

Cheers. 🍻

@cnoon cnoon closed this as completed Sep 6, 2015
@cnoon cnoon added this to the 2.0.0 milestone Sep 6, 2015
@cnoon cnoon self-assigned this Sep 6, 2015
@vijayalangaram
Copy link

Is it right to send encode image through postman
{
"image":"encode detail"
}
i have deserialize issue

@fukemy
Copy link

fukemy commented Oct 12, 2020

still crash in newest alamofire version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants