function file_service_get in Services 7
Same name and namespace in other branches
- 6 services/file_service/file_service.inc \file_service_get()
- 6.2 services/file_service/file_service.inc \file_service_get()
Get all elements from a given file
Parameters
$fid: Number. File ID
Return value
Array. All elements for a given file
1 string reference to 'file_service_get'
- file_service_service in services/
file_service/ file_service.module - Implementation of hook_service().
File
- services/
file_service/ file_service.inc, line 16 - @author Services Dev Team
Code
function file_service_get($fid) {
if ($file = db_fetch_array(db_query('SELECT * FROM {files} WHERE fid = %d', $fid))) {
$filepath = file_create_path($file['filepath']);
$binaryfile = fopen($filepath, 'rb');
$file['file'] = base64_encode(fread($binaryfile, filesize($filepath)));
fclose($binaryfile);
return $file;
}
else {
return services_error(t('There is no file with the given ID.'));
}
}