BluePic
BluePic copied to clipboard
Mysterious Endpoint
I am trying to add a double-tap-to-like function. However, I failed to update the database. One thing I notice is that the mysterious endpoints. How do you choose the right one?
extension BluemixDataManager{
/**
Method updates like
id: Image ID
*/
func updateLike(id:String) {
let requestURL = getBluemixBaseRequestURL() + "/" + kImagesEndPoint + "/" + id // I tried but failed
let request = Request(url: requestURL, method: HttpMethod.PUT)
request.timeout = kDefaultTimeOut
let imageDataArray = BluemixDataManager.SharedInstance.images
for image in imageDataArray{
if image.id == id {
print("\(id)") // I can find out which image is being tapped
let imageDictionary = ["_id": image.id, "_rev": image._rev, "fileName": image.fileName, "caption" : image.caption, "width" : image.width, "height" : image.height, "location" : ["name" : image.location.name, "latitude" : image.location.latitude, "longitude" : image.location.longitude], "like" : image.like + 1]
do {
let jsonData = try NSJSONSerialization.dataWithJSONObject(imageDictionary, options: .PrettyPrinted)
request.sendData(jsonData, completionHandler: { (response, error) -> Void in
if let error = error {
print(NSLocalizedString("Update Like Fail:", comment: "") + " \(error.localizedDescription)") // this one called
}
})
} catch {
print(NSLocalizedString("Update Like Fail", comment: ""))
}
}
}
}
}
I don't think I know what you mean by mysterious endpoint? I think the functionality you are trying to use does not exist on BluePic-Server. I believe this would involve adding a new endpoint for adding likes to an image, in Routes.swift
.
Thanks for replying. Forgive me. I tried but failed to find related documents (create an endpoint on server side)
Hello, we are in the middle of migrating the code to Swift 3.0 and also addressing some technical debt and issues/defects. We hope to be done with this pretty soon. It would be better to incorporate any new functionality after we complete these tasks. We will get back to you and let you know once we are done so we can continue the discussion. Thanks so much for your interest in BluePic!