File information in code behind

2 posts, 0 answers
  1. Greg
    Greg avatar
    1 posts
    Member since:
    Oct 2013

    Posted 27 Nov 2013 Link to this post

    I'd like to lay out a scenario and hopefully someone can help me figure out the best want to implement either the Cloud or Async uploader to solve it. I am using Windows Azure web sites, storage and SQL.

    Our business allows customers to upload medical bills to our site.  We then review those files for overcharges, billing errors, etc.  The uploaded file could be a single bill or a combination of bills all in one file.  After the file is uploaded, I need to capture information about the file as well as other user meta information into our database,

    I love the ease at which the CloudUpload integrates with Azure.  My main question is, what is the best way to capture the information (mainly the keyname) for each file uploaded and insert that information into our database, along with session information identifying the user?

    Right now, I have a button on the page to force a postback, but the postback removes the file upload progress and only seems to capture the last uploaded file.

    One thing I want to prevent, is the user uploading files, not clicking the button and then having orphaned files in our storage.

    Thanks,

    Greg


  2. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 28 Nov 2013 Link to this post

    Hi Greg,

    There are a few approaches that you can use. One of them is to handle the client's OnClientFileUploaded event and call a web service, which stores file name into the database:
    function OnClientFileUploaded(sender, args) {
        var fileInfo = args.get_fileInfo();
        var keyName = fileInfo.keyName;
        //call Web Service to store the file name into the database
    }
    You can keep the session information identifying the user in hidden field.

    Other approach could be to handle OnFileUploaded event, which will be fired after you cause a postback. Note that after the postback this event will be fired for every of the uploaded file.
    protected void RadCloudUpload1_FileUploaded(object sender, CloudFileUploadedEventArgs e)
    {
        string keyName = e.FileInfo.KeyName;
          //Store keyName in db
    }

    Unfortunately at the moment there is no way to prevent automatically uploading. It will start once after a file is selected. You could add a validation, to decrease the chance for the users to upload incorrect files.

    Regards,
    Hristo Valyavicharski
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top