You are here

function pmpapi_pull_create_mock_file in Public Media Platform API Integration 7

Creates a mock file object (i.e., without touching the database) from a file

Parameters

string $uri: The URI of the file

Return value

object A mock file object.

1 call to pmpapi_pull_create_mock_file()
pmpapi_pull_preview in pmpapi_pull/pmpapi_pull.pages.inc
Page callback: Previews a pulled doc without creating a node.

File

pmpapi_pull/pmpapi_pull.pages.inc, line 407

Code

function pmpapi_pull_create_mock_file($uri) {

  // Use just path, in case there's a query_string on the URL
  // it will confuse file_get_mimetype()
  $pieces = drupal_parse_url($uri);
  $file = array();
  $file['fid'] = 0;
  $file['uid'] = variable_get('pmpapi_pull_pull_user', 1);
  $file['filename'] = end(explode('/', $uri));
  $file['uri'] = $uri;
  $file['filemime'] = file_get_mimetype($pieces['path']);
  $file['filesize'] = 1000;

  // let's just fake this
  $file['status'] = 1;
  $file['timestamp'] = REQUEST_TIME;
  return $file;
}