Extending the file upload control

Hi

We have a client that would like to customise the file upload control so that if a file was uploaded that was greater than n size it was saved to a shared drive instead of the Rhythmyx database, the location would also be saved to a hidden field.

I take it i have to write a class that implements IPSRequestPreProcessor. I also need to create two params, MaxSize and FileLocation.

But how do I stop the file from being uploaded into Rhythmyx?

This is for a 6.5.2 system.

Cheers
James

Call IPSRequestContext.removeParameter(“file”). This will remove the parameter named “file” (or whatever your field is named).

You should also remove the other “meta” fields: file_type, file_size, file_ext, etc.

You should not need to actually change the control, just add your pre-exit to the content editor.

Dave

I modified a copy of the PSFileInfo class to check if the length of the file was greater than a specified value and if it was to copy the uploaded file to a network share. When called this file is being created in the network share afterwhich an error is returned.

After debugging the exit looks to be called twice when the content item is inserted. In the first call everything works ok:

  • The file is copied.
  • The file parameters are removed from the request.
    At this point the pathSeparator retrieved via PSHttpUtils.getRequestorDirectorySeperator(request) returns ‘’)

In the second call the file parameter is being processed again. This time the pathSeperator is ‘/’ which means we attempt to write to \SHARE\C: emp\file.txt.

Why are there two calls and do I need to call something else to force the removed parameters to stay removed when they are passed in the second call?

Incidentally when a file is passed that has a size lower than the limit, the file is saved to the database in the first call but the second call does not process the file parameter as it is not in the list of params on the request object.

Setting the required flag to false on the file control resolved the error.