private void validateFormValues(
     Validator validator, string subject, bool requireUploadIfNoFile, Action <Validator, System.Drawing.Image> validateImage, bool mustBeImage)
 {
     BlobFileOps.ValidateUploadedFile(validator, uploadedFile, acceptableFileExtensions, validateImage, mustBeImage);
     if (requireUploadIfNoFile && file == null && !uploadedFile.ValueChangedOnPostBack(AppRequestState.Instance.EwfPageRequestState.PostBackValues))
     {
         validator.NoteErrorAndAddMessage(Translation.PleaseUploadAFile + " '" + subject + "'.");
     }
 }
        private ControlList getUploadControlList()
        {
            var dm = PostBack.CreateFull(id: PostBack.GetCompositeId(postBackIdBase, "add"));

            RsFile file = null;
            var    fi   = FormItem.Create(
                "",
                new EwfFileUpload(),
                validationGetter: control => new EwfValidation(
                    (pbv, validator) => {
                BlobFileOps.ValidateUploadedFile(validator, control, acceptableFileExtensions, ValidateImage, AcceptOnlyImages);
                file = control.GetPostBackValue(pbv);
            },
                    dm));

            dm.AddModificationMethod(
                () => {
                if (file == null)
                {
                    return;
                }

                var existingFile = files.SingleOrDefault(i => i.FileName == file.FileName);
                int newFileId;
                if (existingFile != null)
                {
                    BlobFileOps.SystemProvider.UpdateFile(existingFile.FileId, file.FileName, file.Contents, BlobFileOps.GetContentTypeForPostedFile(file));
                    newFileId = existingFile.FileId;
                }
                else
                {
                    newFileId = BlobFileOps.SystemProvider.InsertFile(fileCollectionId, file.FileName, file.Contents, BlobFileOps.GetContentTypeForPostedFile(file));
                }

                if (NewFileNotificationMethod != null)
                {
                    NewFileNotificationMethod(newFileId);
                }
                EwfPage.AddStatusMessage(StatusMessageType.Info, "File uploaded successfully.");
            });

            return(ControlList.CreateWithControls(
                       true,
                       "Select and upload a new file:",
                       fi.ToControl(),
                       new PostBackButton(dm, new ButtonActionControlStyle("Upload new file"), false)));
        }