EPrints Technical Mailing List Archive

Message: #00787


< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First

[EP-tech] Re: Messages do not work in UploadMethod - action_add_format (Error)


Hi,

Is this on the latest EPrints? I thought messages could be displayed in an ajax context now (perhaps something wrong with the upload component...).

If you're interested, you may want to look into putting your "scan" hook into:

- a trigger (when a document object is committed to the DB, see EP_TRIGGER_AFTER_COMMIT for example)

- when the above trigger's called you may create an Event which will perform the scan (this way the uploader doesn't hang on the scan) and take action if necessary.

Voila, I'll look into the other problems tomorrow,

Seb.

 

On Thu, 21 Jun 2012 18:17:27 +0000, <rchilliard@mun.ca> wrote:

Hi All,

   In the process of attempting to build a hook for on-demand virus scanning of uploaded files, I've been tinkering with action_add_format within UploadMethod.pm as it seems the most relevant location to hook in. In the case of a bad file, I want to toss the uploaded file and display an error message, comparable to that which would show up for a file transfer that otherwise fails: as an example, the existing "file didn't show up" handling code:
 
--- snip ---
if( !EPrints::Utils::is_set( $filename ) || !defined $fh )
        {
                $processor->{notes}->{upload} = {};
                $processor->add_message( "error", $self->{session}->html_phrase( "Plugin/InputForm/Component/Upload:upload_failed" ) );

                return 0;
        }
--- snip ---

In our case, this test would be replaced for an assessment of the virus scan results on the file, giving pass/fail.

In building this process, I think I've found a bit of a bug - the current upload configuration, using the ajax code to display the upload progress bar, seems to ignore any add_message() content from ever reaching the workflow page. No matter where in the subroutine an add_message call is placed; when it is called as a result of a file being uploaded via the form's File control, no message appears.

I've found this to be an issue on Firefox, IE and Chrome. Interestingly, on IE, the name of any file selected by the form control persists in the control after upload; if the "Upload" button is then clicked with the form in this state, add_message calls within action_add_format are respected, however the progress bar does not display.

As is, it seems the message feedback for any sort of upload trouble seems to be broken, can any others confirm?

Cheers,
Casey


Casey Hilliard
PC Consultant,
Health Sciences Library / QE2 Systems,
Memorial University


This electronic communication is governed by the terms and conditions at http://www.mun.ca/cc/policies/electronic_communications_disclaimer_2012.php