Upload Strategy

11 posts by 2 authors in: Forums > CMS Builder
Last Post: January 5, 2018   (RSS)

By jenolan - December 8, 2017

I wish to expand the upload strategy, see how to do it by passing the instance to upload_storage_strategy() great, but I thought there was a custom.php widget available to add stuff like this or I am just thinking of the js/css?

Don't want to do it as a plugin just want to add some code, did I miss something or should I ask for a custom.php to be loaded by the init process.

Thanks
Larry

---

By Dave - December 22, 2017

Hi Larry, 

All that code might change a bit when we implement a new uploader.  The original upload strategy was designed to support different methods.  We have a (internal, unsupported) plugin that stores uploads on Amazon S3.  So it was to have support for switching to/from that.

What are you wanting to do? 

Dave Edis - Senior Developer
interactivetools.com

By jenolan - December 22, 2017

At the moment all uploads go to one directory which is ok for smallish ones, I have implemented one where if it is the fieldName gallery it adds yyyy/mm to the file name.

So a a general thing the upload path allows you to put /my/main/path/{yyyy}/{mm} (or whatever) the url path would still be /my/main/path as the y/m is added to the file name in the uploads table. This is similar to what wordpress does for its uploads.

FWIW ... having more than a few hundred files in a single directory is a bad idea ;-)

---

By Dave - December 22, 2017

Check out the 'upload_saveAsFilename' plugin hook.  We've used that before to modify the name and/or path uploads are stored with on save.

Dave Edis - Senior Developer
interactivetools.com

By jenolan - December 22, 2017 - edited: December 22, 2017

Will have a gander, after the latest wordpress hack I am going to have to accelerate my move with the other site ... hohum

Just had a look ... no schema passed so can not process per field/table

---

By Dave - December 22, 2017 - edited: December 22, 2017

Try $GLOBALS['schema']

These are also available (from /lib/menus/default/action_handler.php)

global $TABLE_PREFIX, $tableName, $escapedTableName, $action, $schema, $CURRENT_USER, $hasEditorAccess, $hasAuthorAccess, $hasViewerAccess, $hasViewerAccessOnly, $hasAuthorViewerAccess, $isMyAccountMenu, $isSingleMenu;

Dave Edis - Senior Developer
interactivetools.com

By jenolan - December 22, 2017

OK will look at that .... one thing that would be handy but probably too hard is a settings handler. Really hate coding the form stuff whinge moan I know

---

By jenolan - January 5, 2018

What I have done is that for each of my areas, if I want a gallery I name the field 'gallery' set the upload information and my code adds the year/month to the name.

The problem (I think) with what you want is that the category is not necessarily set when the upload code is called. The actual file name is not really an issue if you are showing them on the site or am I missing something?

---

By jenolan - January 5, 2018

Assuming the data (ie the name year model etc) is available, it would be possible to do it either when the record is saved or as a cron job, that's assuming you want the file names changed naturally.

---