CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Inserting Files "Manually"
Pages: [1]

Author Topic: Inserting Files "Manually"  (Read 1174 times)

FredJones

  • Guest
Inserting Files "Manually"
August 25, 2008, 07:45:25 am
I have a Drupal module (D5 CiviCRM 2.0.5) which uploads a file, stores it correctly in my $config->customFileUploadDir directory, and inserts a record in civicrm_file.

As far as I can see, that's what is necessary to manually insert a file into CiviCRM. This file should appear in our custom "Pictures" tab and the module also inserts a record in civicrm_value_1_Pictures correctly. Here are two lines from civicrm_value_1_Pictures:

Code: [Select]
| 10 |   1  | image/jpeg  | id2.MANUALUPLOAD.jpg     | NULL | NULL | 2008-08-25 08:37:31 |
| 11 | NULL | image/jpeg  | autouploaded.jpg.unknown | NULL | NULL | 2008-08-25 09:12:57 |

and here are two from  civicrm_file:

Code: [Select]
|  5 |         1 |         2 |              10 |
|  6 |         1 |         5 |              11 |

The file for contact 5 was uploaded regularly, via the custom tab and it works fine. The file for contact 2 was uploaded manually. The DB records look the same to me. The files appear the same via ls -l :

Code: [Select]
-rw------- 1 apache    apache   14920 Aug 25 09:12 autouploaded.jpg.unknown
-rw------- 1 apache    apache    6864 Aug 25 08:49 id2.MANUALUPLOAD.jpg

I have determined that the call to

$entityFileDAO->find( true )

in the file CRM/Core/BAO/File.php at about line 57 returns zero for the manually uploaded file, whereas of course if it was good, it would return 1.

I'm guessing that perhaps there is another DB table which I must update, because everything else looks good to me. I tried playing with the name by attached 'unknown' to it but that doesn't help. I tried adjusting the file_type_id to be 1 or NULL, but that doesn't help.

Thank you.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Inserting Files "Manually"
August 25, 2008, 11:59:46 am

your best bet would be to check the query it generates and see why it fails for your case

From the code it seems like the 3 things it look for are entityTable (optional), entityID and fileID in the entity_file table. check the values for the manual vs regular upload code and that might help you out.

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

FredJones

  • Guest
Re: Inserting Files "Manually"
August 25, 2008, 12:12:12 pm
Quote from: Donald Lobo on August 25, 2008, 11:59:46 am
From the code it seems like the 3 things it look for are entityTable (optional), entityID and fileID in the entity_file table.

Ah, the entity_file table! That's what I was missing. I didn't realize that I also needed to update that table. I did it now and it works!!

PLEASE tell me where the code is you are referring to. I tried to trace $entityFileDAO->find( true ) back but I failed to find the code. Perhaps it looks in that table merely by virtue of the class name CRM_Core_DAO_EntityFile ?

You should know that for us mere mortals, many parts of the overall CiviCRM system are a bit mysterious. :)

Thanks!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Inserting Files "Manually"

This forum was archived on 2017-11-26.