EndOfStreamException occuring during file upload...

  •  04-15-2009, 11:31 AM

    EndOfStreamException occuring during file upload...

    Hi -
     
    We are trying to stream the uploaded file(s) from the upload temp directory to an external location once each file is uploaded.  We have implemented an eventhandler for the OnFileUploaded event in which we do the following...
     
    protected void ajaxUploader_OnFileUploaded(object sender, CuteWebUI.UploaderEventArgs args)
        {
                using (System.IO.Stream uploadedStream = args.OpenStream())
                {
                    try
                    {
                        byte[] fileData = new byte[uploadedStream.Length];
                        uploadedStream.Read(fileData, 0, fileData.Length);
     
                        // stream document to external location and write document meta-data to database
                    }
                    catch (Exception ex)
                    {
                        // Wrap exception to provide additional context...
                        string messageFormat = "An exception occurred uploading a file!  Additional information below:\n\nFileGuid:{0}\nFileName:{1}\nFileSize:{2}\nTempFilePath:{3}";
                        ApplicationException uploadException = new ApplicationException(String.Format(messageFormat, args.FileGuid,
                            args.FileName, args.FileSize, args.GetTempFilePath()), ex);
                       
                        // log the exception (EntLib 3.1)
                        Common.Utility.ProcessUnhandledException(uploadException);
                    }
                    finally
                    {
                        uploadedStream.Close();
                    }
                }        
        }
     
     
    Unfortunately, the EndOfStreamException is doesn't appear to be happening within the event handler and we aren't trying to stream the document anywhere else...  This results in the AjaxUploader control catching the exception and writing the message to an alert box (see below)...
     
     
    The primary question I have to start with is where is this exception being caught so that I can implement the appropriate try/catch to narrow down why this exception is happening...  Having just the exception message written to an alert box doesn't give us enough information to identify why this behavior is occurring.
     
    We have not specified the appsetting to override the UploaderTemp directory and have granted full access to the virtual directory, but the files are never uploaded to the UploaderTemp folder (this is likely the cause of the EndOfStreamException...)
     
    The code above works fine in our DEV environment, but we are running into this exception in our UAT enviroment... being able to log the detailed exception with stacktrace will help us identify any environment configuration issues that we are seeing.
     
    Thanks,
     
    Casey
    Filed under:
View Complete Thread