I have had a feature request for flash node to put upload limits in to control how much a user can upload in a single file, and in total - basically what the upload module does for other files.

I was going to lift the code from upload, mod it slightly to use a separate set of variables, and use that for flash node, but when I went looking behind the scenes I got a bit confused.

Flash node calls file_save_upload, and I can ask it to use file_validate_size to check limits. However, file_validate_size then calls file_space_used to work out how much the user already uploaded. That function tots up *everything* the user uploaded, not just files of a specific type or criteria (aside - does it? the code looks like it tries to do a user specific check if the uid is null and returns the total if a uid is given??)

Anyhow, if I supply a total upload limit specifically for flash node the limit might be reported as exceeded as a result of the user uploading other things in other modules. That implies to me that the upload maximum is a "global" setting since it is the total of all files that have been placed in the {files} table.

Does that mean I should require users to enable the upload module if they want to enforce upload limits, or repeat the upload settings and share the same variables in flash node, effectively meaning the user can set the limit in either place? Alternatively, if the setting is global should the settings even be somewhere in the core?

For dev work I have gone with the "shared variable" approach, so if you activate flash node, but not upload, you can set file limits, and if you were to then activate upload you would simply share the same setting. As far as I can tell there is no way to have an "upload" limit and a "flash node" limit unless I write an entire new custom file size validator in flash node. That's not a problem, but I don't want to duplicate code unnecessarily.

Or am I missing something/going about things the wrong way here? Flash node stores the uploaded file data in {files}, but should it be writing to its own table. I just assumed when I started flash node that {files} was the appropriate place to store all file related data.

Hope this makes sense, and thanks for any help or guidance!

Stuart

Comments

Stuart Greenfield’s picture

the code looks like it tries to do a user specific check if the uid is null and returns the total if a uid is given??

Not just me - someone else has spotted this and also provided a patch!

________

Just five more minutes...

www.stuartandnicola.com