Ok I am going to post what I did to make this work with services. I'll also include a bit of information about my specific use-case because I don't see any list of steps anywhere else on the internet to make this happen, so maybe it'll make it easier for someone along the line.
Here's the optional part of the answer:
I was doing this in PhoneGap. To pass the image data from a mobile device via PhoneGap to a user, I did the following:
navigator.camera.getPicture(saveProfile,
function(message) { alert('get picture failed'); },
{ quality: 50,
destinationType: navigator.camera.DestinationType.DATA_URL,
sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY }
);
function saveProfile(image) {
json.image = image;
}
$.ajax({
url: "http://drupal/services_endpoint" + uid,
type: 'PUT',
contentType: 'application/json',
data: JSON.stringify(json)
}
);
And now the actual answer:
After finding this link here: Create file through services
I released I could do something similar:
function MY_MODULE_services_request_preprocess_alter($controller, &$args, $options) {
switch ($controller['callback']) {
case '_user_resource_update':
if (isset($args[1]['image'])) {
$data = base64_decode(trim($args[1]['image']));
$finfo = finfo_open();
$mime_type = finfo_buffer($finfo, $data, FILEINFO_MIME_TYPE);
finfo_close($finfo);
$ext = $mime_type ? str_replace('image/', '', $mime_type) : 'png';
$file_name = uniqid();
$file = file_save_data($data, 'public://users/' . $file_name . '.' . $ext, FILE_EXISTS_REPLACE);
file_usage_add($file, "user", "user", $args[0]);
$args[1]['field_picture'] = array(
'und' => array(
0 => array(
'fid' => $file->fid,
),
),
);
}
}
}
This will generate a random file name. I'm not sure if that'll work perfectly for everyone, but it worked for my use-case.
Anyway, that is a basic way to get image data from a mobile device (iPhone in this case) into a Drupal user in one RESTful call.