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) »
  • Support »
  • Using CiviCRM »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • CiviCRM uploaded files and Drupal 'File Field Paths' module
Pages: [1]

Author Topic: CiviCRM uploaded files and Drupal 'File Field Paths' module  (Read 1667 times)

seGAP

  • I’m new here
  • *
  • Posts: 11
  • Karma: 0
  • CiviCRM version: 4.0
  • CMS version: Drupal 7
  • MySQL version: 5.0
  • PHP version: 5.2
CiviCRM uploaded files and Drupal 'File Field Paths' module
March 21, 2013, 11:12:22 pm
Hi,

We would like to have some Contact-related structure to the /sites/default/files/civicrm directory, and we're wondering if anyone has attempted this using the Drupal 'File Field Paths' module (or any other approach).

The aim being to introduce an extra directory layer, something like: /sites/default/files/civicrm/{contact-id}/

Our primary aim is to avoid a single large directory of all uploads.

Anyone had any success with this?

Bryan
Bryan

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: CiviCRM uploaded files and Drupal 'File Field Paths' module
March 22, 2013, 04:39:36 am
Quote from: seGAP on March 21, 2013, 11:12:22 pm
Anyone had any success with this?

Don't think anyone ever tried. If you want CiviCRM to store uploaded files using that method, you would need to write some custom code.
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

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: CiviCRM uploaded files and Drupal 'File Field Paths' module
March 22, 2013, 08:31:34 am

If you are willing to do this via code / manipulating DB tables, you can set the path in the civicrm file table to follow the hierarchy

I do this for the school, where i store report cards based on school year and semester. I update the tables via SQL directly and then use CiviCRM to display them which works out very nicely

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

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: CiviCRM uploaded files and Drupal 'File Field Paths' module
March 22, 2013, 08:34:17 am
Quote from: Donald Lobo on March 22, 2013, 08:31:34 am
I do this for the school, where i store report cards based on school year and semester. I update the tables via SQL directly and then use CiviCRM to display them which works out very nicely

How do you upload the images?
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

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: CiviCRM uploaded files and Drupal 'File Field Paths' module
March 22, 2013, 09:14:58 am

i have ssh access, so i upload the files directly

The code that creates the sql for the various tables and the directory structure is here:

http://svn.civicrm.org/sfschool/trunk/org.civicrm.school/bin/addReportCards.php

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

seGAP

  • I’m new here
  • *
  • Posts: 11
  • Karma: 0
  • CiviCRM version: 4.0
  • CMS version: Drupal 7
  • MySQL version: 5.0
  • PHP version: 5.2
Re: CiviCRM uploaded files and Drupal 'File Field Paths' module
March 22, 2013, 05:26:38 pm
Thanks to both of you for the feedback.

We would need to be using CiviCRM to do the uploading, so is there a post-upload Hook where we could hang some custom code to move the uploaded file to the appropriate sub-directory, and to make the corresponding change to the Tables?

Bryan

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: CiviCRM uploaded files and Drupal 'File Field Paths' module
March 22, 2013, 05:48:05 pm

good idea, u can use the postProcess hook and then fix the one table (where the path is) and rename the file to the right place

lobo

p.s> the reason i scripted it was because we handle a few hundred report cards and i not want to click / upload etc
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

seGAP

  • I’m new here
  • *
  • Posts: 11
  • Karma: 0
  • CiviCRM version: 4.0
  • CMS version: Drupal 7
  • MySQL version: 5.0
  • PHP version: 5.2
Re: CiviCRM uploaded files and Drupal 'File Field Paths' module
March 24, 2013, 02:31:29 pm
Thanks for the Hook hint... we'll now work out where this fits with our other CiviCRM priorities.

I'll squeeze in one more kind of related issue, which we haven't been able to answer from our searches... changing the file size of images at the time of upload.

I'm guessing we'd use the same Hook, but I'm unsure of how we'd code the change of size.

note:
I have found solutions using Drupal Views & ImageCache at the time of display, but we'd prefer to control the images when they are first uploaded.

Also found mention of something on Image Resizing maybe happening in 4.x, but I believe we're trapped at 4.0 because of our PHP version, which in turn is restricted by an App that we can't yet retire.
 
Thanks,
Bryan

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: CiviCRM uploaded files and Drupal 'File Field Paths' module
March 24, 2013, 02:42:40 pm

If you are implementing the postProcess hook, i would keep things simple and do it in that hook when you move it into the directory. You can also keep a copy of the original for record keeping

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

seGAP

  • I’m new here
  • *
  • Posts: 11
  • Karma: 0
  • CiviCRM version: 4.0
  • CMS version: Drupal 7
  • MySQL version: 5.0
  • PHP version: 5.2
Re: CiviCRM uploaded files and Drupal 'File Field Paths' module
March 26, 2013, 12:38:21 pm
Thanks,

Are you aware of any other custom code for Image Resizing that we could clone?
Bryan

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • CiviCRM uploaded files and Drupal 'File Field Paths' module

This forum was archived on 2017-11-26.