In Firefox on Mac 10.5, I found that if I clicked on the URLs for attachments imported with file_import, I got a 404 - unless I right-clicked for "save as". This is not desirable behavior because most end users won't try a save-as if the initial download click didn't work.

The root problem is that the nid field was not being set in the upload table. Once I manually repaired this in the database table, the downloads worked as expected.

To patch file_import.module, I replaced lines 374-376 with the following:

...
db_query("INSERT INTO {upload} (fid, nid, vid, description, list) VALUES (%d, %d, %d, '%s', %d)",
      $fid,
      $nid,
      $vid, 
...

This takes care of the problem on my installation. Since it is the first time I've been able to patch a module, I'm not sure what the proper procedure is for moving it along in the issue queue. Please let me know if I need to take further action.

Comments

AniKarenina’s picture

I'm afraid that I don't know how to create a proper patch to submit, but here's a diff for these changes:

@@ -370,9 +370,10 @@
               time());
 
             if (!db_error()) {
-              $fid = db_last_insert_id('files', 'fid');
-              db_query("INSERT INTO {upload} (fid, vid, description, list) VALUES (%d, %d, '%s', %d)",
-                $fid, 
+	          $fid = db_last_insert_id('files', 'fid');
+              db_query("INSERT INTO {upload} (fid, nid, vid, description, list) VALUES (%d, %d, %d, '%s', %d)",
+                $fid,
+ 				$nid,
                 $vid, 
                 $form_state['values']['title'][$index],
                 $list);