I'm trying to set a user picture (fid) for a user after successfully uploading a photo using Drupal services and DIOS SDK. I upload the file using the "fileSave" method of DIOS SDK (DIOSFile). Services then returns an "fid" for the user picture that was just uploaded. When I try to set the fid for the user picture field for the user who is currently logged in, it doesn't get set. There is no error, it actually returns successfully, but if I check on the "picture" field in the users table of the database, nothing is set. I can update other data that is attached to a user such as username, email, password and other custom fields so I don't think it's a permission issue.
I've tried the following code and many variations of it, but nothing seems to updated the "picture" field.
_userUpdateParams = [NSMutableDictionary new];
NSString *fid = @"22"; //For demonstration purposes, I'm hard-coding an fid value.
if (username)
[_userUpdateParams setValue:username forKey:@"name"];
if (password)
[_userUpdateParams setValue:password forKey:@"current_pass"];
if (newPassword)
[_userUpdateParams setValue:newPassword forKey:@"pass"];
if (email)
[_userUpdateParams setValue:email forKey:@"mail"];
if (fid)
[_userUpdateParams setValue:fid forKey:@"picture"];
if (uid)
[_userUpdateParams setValue:uid forKey:@"uid"];
[DIOSUser userUpdate:_userUpdateParams
success:^(AFHTTPRequestOperation *operation, id responseObject) {
...
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
...
}];
This post suggested to use the "fid" of the file: https://github.com/kylebrowning/drupal-ios-sdk/issues/28
First of all i have created a user in drupal with a userProfile related (with PID).
Than i have used this method with 3 parameters:
nameEntity = name of entity drupal to update;
fid = you know what this mean;
entityID = id of entity to update;
finally update the entity!
works for me: