Skip to content

Instantly share code, notes, and snippets.

@McFateM
Created August 24, 2017 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save McFateM/9f81334d8d13b74ed2c20a1961ff910a to your computer and use it in GitHub Desktop.
Save McFateM/9f81334d8d13b74ed2c20a1961ff910a to your computer and use it in GitHub Desktop.
Custom logic for islandora_multi_importer_remote_file_get in lines 4-16
// If the file is not from a .zip...
function islandora_multi_importer_remote_file_get($url) {
$parsed_url = parse_url($url);
/* MAM 2-August-2017 New logic, assumes the file is somewhere in the public://imi_files path */
$basename = drupal_basename($parsed_url['path']);
$pattern = "/$basename/";
$options['key'] = 'filename';
$file = file_scan_directory( "public://", $pattern, $options );
$url = $file[$basename]->uri;
return drupal_realpath($url);
/* MAM 2-August-2017 Replacing below logic with code above.
$remote_schemes = array('http', 'https', 'ftp', 'ftps', 'smb', 'nfs');
if (!in_array($parsed_url['scheme'], $remote_schemes)) {
// if local file, return the path.
return drupal_realpath($url);
}
// Check if the temp directory exists if there is no other file named equally
// Create if needed.
//$tmp_directory = islandora_multi_importer_temp_directory();
$local = "public://" . drupal_basename($parsed_url['path']);
if (!file_exists($local)) {
return system_retrieve_file($url, $local, FALSE, FILE_EXISTS_REPLACE);
}
else {
return $local;
} */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment