This doesn't seem to be working for me,

Here's what I've done. Created a file content type. Under file sources I have two options, Remote File and Remote URL Text Field. I'm not sure what one was enabled by this module. The first option lets me select a remote file but it still transfers to file locally to the filesystem. The 2nd option is stranger. When I use that I can type in a remote url but the upload button says "transfer" and returns some ajax error without doing anything. Neither seem to be right because I don't want to transfer the files locally.

Am I doing something wrong? What file source should I be selecting?

Comments

timefor’s picture

Version: 7.x-1.0 » 7.x-1.x-dev

I think I found the issue, when I upgraded to the latest dev release and uninstalled File Field Paths module this worked as expected using "Remote File" as the source. The File Fields Path module may be a conflict.

webadpro’s picture

The submit button shouldn't say "Transfer" but "Select".

Although in the field options, make sure you check: 'Remote File'. Although if you think you have found a bug, ill look it up. A patch is always welcome too.

webadpro’s picture

Status: Active » Closed (works as designed)
burningdog’s picture

Status: Closed (works as designed) » Active

I can confirm this issue with filefield_paths module - if it's enabled, then on node save it moves the uploaded file to a new (local) location defined by a replacement pattern, and if no replacement pattern is defined it simply moves it to public://filename.jpg

This because of the following line in function filefield_paths_filefield_paths_process_file()

<?php if (file_prepare_directory($dirname, FILE_CREATE_DIRECTORY) && file_move((object) $old_file, $file['uri'])) {
?>

The file_move attempts to move the existing file to a new location (defined by $file['uri']), which is local, which defeats the point of Remote File Source. I've looked through Filefield Paths and there doesn't seem to be a way to stop the call to filefield_paths_filefield_paths_process_file() - which is where the file_move happens.

The simplest idea seems to be to add an additional checkbox to the Filefield Path settings called "Skip processing the file", check it, and then add a check for that here:

<?php
function filefield_paths_filefield_paths_process_file($type, $entity, $field, $instance, $langcode, &$items) {
  if (isset($instance['settings']['filefield_paths'])) {
    $settings = $instance['settings']['filefield_paths'];
    // Here is the added code
    if ($settings['skip_process_file']) {
      drupal_set_message('GET THE HELL OUT OF HERE!');
      return;
    }
?>

This code works, to keep the file remote, not local.

I tried playing with hook_module_implements_alter() to unset the value of "filefield_paths" when filefield_paths called <?php foreach (module_implements('filefield_paths_process_file') as $module) {?> but turns out that hook only allows changing the weight value, not stopping a call to an undesired function.

So, looks like we need a patch to filefield_paths, as I can't figure out how to override the filefield_paths behaviour from Remote File Source. Unless there's another suggestion?

burningdog’s picture

Status: Active » Fixed

I've proposed a patch at #1361884: Remotes files should not be processed which fixes this issue. Turns out other people using remote files (like youtube or vimeo urls) are having the same issue, so it makes sense to patch Filefield Paths to not process *any* remote files.

webadpro’s picture

Status: Fixed » Closed (fixed)

I dont think we can do much within Remote File Source. This is a File field Paths issue.