RadAsyncUpload can't get custom metadata on server

2 posts, 0 answers
  1. Scott
    Scott avatar
    17 posts
    Member since:
    Jul 2012

    Posted 09 Nov 2017 Link to this post

    I'm using the RadAsyncUpload to upload files to a custom handler which stores the files into our database.  The custom handler returns a key value for the file which I want to then use during form postback to attach those uploads to the current record (which may be a brand-new record).  I can see the custom returned data on the client in OnClientFileUploaded() by using args.get_fileInfo().  From that standpoint I have everything working, upload, saving, validation, returning the file key.

    Here's my definition of RadAsyncUpload:

                               <telerik:RadAsyncUpload RenderMode="Lightweight"

                                    ID="AttachmentAsyncUploader"
                                    runat="server"
                                    CssClass="async-attachment"
                                    MultipleFileSelection="Automatic"
                                    UploadedFilesRendering="BelowFileInput"
                                    OnClientFileSelected="OnClientFileSelected"
                                    OnClientFileUploading="OnClientFileUploading"
                                    OnClientValidationFailed="OnClientValidationFailed"
                                    OnClientFileUploaded="OnClientFileUploaded"
                                    OnClientFileUploadRemoved="OnClientFileUploadRemoved"
                                    MaxFileSize="26214400"
                                    DropZones="#DropZone"
                                    HttpHandlerUrl="~/FileUploader.ashx"
                                    HideFileInput="true">
                                    <Localization Select="Select Files for Upload" />
                                </telerik:RadAsyncUpload>

    Now the user posts the form back, so I call AttachmentAsyncUploader.UploadedFiles() which gives me a list of the files that were uploaded, but I can see no way to access the custom fileInfo fields that were returned by the handler.  Obviously just the file name isn't enough to figure out which attachments need to be attached to the newly created records.

    Here is how I'm building and returning the meta-data from the custom handler, FileUploader.ashx (most importantly AttachedFileGuid):

                var result = CreateDefaultUploadResult<FileUploaderResult>(file);

                 result.AttachedFileGuid = InsertFile(file);

                 return result;

    What is the expected way to get the full information about the uploaded files back to the postback?  Obviously, I can build my own field to store all that, but it seems an awful hack to use RadAsyncUpload and then just ignore it completely on postback.

    Thanks in advance,

  2. Vessy
    Admin
    Vessy avatar
    2011 posts

    Posted 14 Nov 2017 Link to this post

    Hi Scott,

    You can find detailed steps on both how to add and access a custom field of the uploaded file in this help article:
    https://docs.telerik.com/devtools/aspnet-ajax/controls/asyncupload/how-to/how-to-extend-the-radasyncupload-handler#send-custom-information-to-and-from-the-handler

    The following demo implements this approach, so you can examine its whole source code and see if it differs somehow the approach used by you:
    http://demos.telerik.com/aspnet-ajax/asyncupload/examples/imageuploader/defaultcs.aspx

    Regards,
    Vessy
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top