Storing file in CCK field does not honor filefield path setting

mrfelton - July 20, 2009 - 10:34
Project:Media Mover
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review
Description

I have a cck filefield set up to save files in a specific directory within my files directory. However, when a file gets attached to this cck field by media_mover, it is stored in the top level of the files directory, not in my specified path.

#1

jlevis - July 28, 2009 - 21:10

I am having the same problem.

When I re-save the node, the file is then moved to the correct place.

I'd rather not have to re-save the node everytime, however.

#2

szczym - September 8, 2009 - 17:07

i get the same problem

#3

arthurf - September 15, 2009 - 04:22
Status:active» needs review

Can you check out the latest development version? I've done some modifications to how the file path is handled which I hope should resolve this.

#4

szczym - September 17, 2009 - 04:00

I just tested newest cvs version (2009-Sep-17 after #263908 commit ) on fresh* drupal install. its still not possible to save to filefiled with special path defined. i get error

    * The selected file sites/default/files/media_mover/ffmpeg/thumbnails/2/output_1.avi.thumb2_2.jpg could not be uploaded, because the destination sites/default/filesthumbnails is not properly configured.
    * The selected file sites/default/files/media_mover/ffmpeg/thumbnails/2/output_2.avi.thumb2.jpg could not be uploaded, because the destination sites/default/filesthumbnails is not properly configured.

* for all today`s tests im using one single fresh install
BTW after not storing the thumbnail, it did placed properly the flv file in filefiled (its been not placing it before, see -> #486206: Files transcoded but not added to filefiled

#5

szczym - September 17, 2009 - 04:01
Status:needs review» needs work

#6

arthurf - September 17, 2009 - 12:09

So it looks the issue is:

because the destination sites/default/filesthumbnails is not properly configured.

Note the file path is wrong- Drupal can't create that directory. In watchdog, is this error coming from ffmpeg, or mm_cck?

#7

szczym - September 17, 2009 - 14:07

its from filesystem

AttachmentSize
e.png 145.69 KB
file system.png 145.79 KB
log.png 224.69 KB

#8

arthurf - September 17, 2009 - 14:17

Can you provide the log entry for the ffmpeg entry? I'm wondering if that is the source of the error.

#9

szczym - September 17, 2009 - 14:30

sorry, my mistake: sites/default/files was not writable so i did chmod a+w ~/tescik2/sites/default/

than i re-submit the filefiled setting form with the custom path and sill getting error but from "MM Content"

it get a bit messy all ready, maybe i shout test it some other way?

AttachmentSize
zrzut_ekranu.png 137.95 KB
zrzut_ekranu-1.png 143.88 KB
zrzut_ekranu-2.png 189.84 KB
zrzut_ekranu-3.png 138.75 KB
zrzut_ekranu-4.png 134.36 KB

#10

arthurf - September 17, 2009 - 14:32

In the watchdog log, can you see if the file referenced in event 57 (http://drupal.org/files/issues/zrzut_ekranu-3.png) is on the file system?

#11

szczym - September 17, 2009 - 14:36

yes, its there

#12

szczym - September 17, 2009 - 14:56

also on hd is no directory defined here (look: screenshot)

AttachmentSize
destatation.png 112.64 KB

#13

szczym - September 17, 2009 - 15:06

Seems like the issue might be related to #564064: specified path has no effect

#15

szczym - September 17, 2009 - 15:25

with dev version of filefiled the issue is still present despite #275293: Uploading to files/subfolder leads to files/ instead files/subfolder

AttachmentSize
dev-also-problem.png 294.03 KB
couldnot.png 281.35 KB

#16

szczym - September 17, 2009 - 15:34

SORRY, mistake: the #275293: Uploading to files/subfolder leads to files/ instead files/subfolder is for 5-x version

but any way dev version of filefiled is also not producing proper dir in /files. i will test the 3.0 version then according to #564064: specified path has no effect

#17

arthurf - September 17, 2009 - 17:43

Using filefield-3-0 things work correctly for me. Can you try upgrading and see if that works for you?

#18

davebv - October 14, 2009 - 15:39

I think I just post a related topic here: http://drupal.org/node/604374

I get duplicate files, one stored in the path configured in filefield path settings and the other one in the root folder for files in drupal setup.

#19

brunodbo - October 18, 2009 - 10:04

Using Filefield 3.x, things work almost correctly here. When I use tokens in the file path settings (eg. to automatically create a YY/MM/DD file directory structure), new directories aren't being created (eg. the 'DD' directory of the YY/MM/DD token path).

So: things work fine when the file path's directory exists. When a directory doesn't exist and should be created on a token basis as configured in file path settings, the upload fails.

(Note: I chmodded /sites/default/files to 777 in my tests to be sure it wasn't a directory permissions problem).

#20

brunodbo - October 19, 2009 - 20:19

Did some more testing: it seems that the upload fails (see #19) because token is creating files instead of directories (I'm assuming it's token that's doing this).

For example, when the file field is configured with a file path like [site-date-yy]/[site-date-mm]/[site-date-dd], token creates a file called '19' (today is the 19th) in /sites/default/files/09/10, instead of a directory with that name (the '09' & '10' directories already existed).

This leads to an incorrect $filepath in mm_cck_field_filefield() (mm_cck.module, line 514), so the upload fails.

(When I test the same field using the node form, the filefield behaves normally: token creates a directory, and the file is being saved.)

Any idea why this is happening with mm_cc?

#21

arthurf - October 30, 2009 - 01:29

can you give me the input file name and the output file name? I just want to make sure i have a better idea of what's going on

#22

brunodbo - November 2, 2009 - 12:13

Since the upload fails (*), I don't have an output file name. Or am I mis-understanding your question?

(*) By 'upload', I mean the copy action from /files/media_mover/ffmpeg/converted// to my specified (token-created) directory path in the filefield's config.

#23

futrick - November 10, 2009 - 16:12

It might have to do with ownership of the subfolder.
Do a long listing (ls -l) to see who's set as the owner

If you create the subfolder then obviously you become the owner.

In my experience fileupload will only honor the path if apache is the owner.
If you set the fileupload path and let Drupal create the subfolder on the fly (on first upload) then it'll work.

#24

thepiano - November 11, 2009 - 16:44

futrick,

I have set the owner to apache for files/images, and chmod 777.

I have a CCK field, which has File type, and Image as widget. Path is set to images under system files/ directory.

System files/ directory was set to 777 for testing.

When I upload a picture in the add form, the picture ended up in the files directory.

So, I do not think it's a owner / permission problem.

#25

brunodbo - November 12, 2009 - 13:59

@futrick: I had checked directory ownership & permissions before, they're correct (owned by Apache, with 777 permissions for testing purposes).

#26

arthurf - November 13, 2009 - 21:39
Status:needs work» needs review

I just committed a change to mm_cck_field_widget_files_directory() which should now create the directory path when it doesn't exist. Can you give the development version a go and see if it is working?

#27

brunodbo - November 18, 2009 - 17:11

With the current dev version, I'm getting the following error (in watchdog, coming from mm_cck):

Failed to copy. Source: sites/default/files/media_mover/ffmpeg/converted/1/final_0.mpeg Destination: sites/default/files/media_mover/ffmpeg/converted/1/final_0.mpeg

Shouldn't the destination be the directory set in the filefield's path settings?

#28

brunodbo - November 18, 2009 - 18:30

Did some more testing.

The error above (#27) occurs when I set the filefield's path to use multiple subdirectories in /sites/files/default, something like:

video_tr/[site-date-yyyy]/[site-date-mm]/[site-date-dd]

When I change the filefield's path settings textfield so it contains only one directory, files are saved correctly after being transcoded by Media mover. It works using "a static path" (as in: not using tokens), as well as using token to create the path. In this case, the path is created and the file is saved to the correct location.

When I use mutliple subdirectories, the destination seems to be set incorrectly in mm_cck (and mm_cck throws the error, see #27).

When the path consisting of mutliple subdirectories exists before transcoding the file, things also work as expected.

 
 

Drupal is a registered trademark of Dries Buytaert.