RadAsyncUpload with custom HttpHandler SQL Filestream

4 posts, 1 answers
  1. Jukka
    Jukka avatar
    2 posts
    Member since:
    Jan 2018

    Posted 21 Sep 2018 Link to this post

    Hi,

    i'm developing file management system using RadAsyncUpload with custom HttpHandler.

    System is build with ASP.NET using .NET Framework version 4.6.1 and latest Telerik UI for ASP.NET Ajax.

    Currently i'm using overridden Process-function in my HttpHandler to store the file in database. I have set DisableChunkUpload="true" and EnablePermissionsCheck="false" so it is not using temporary folder to buffer the file data. But it still buffers the data in memory (a guess) before calling Process-function.

    Uploaded files can be large and there can be over 100 files uploading at once. So i wonder if there is a way to get the uploaded file's InputStream at beginning of the upload, so i can stream it directly to the database as it uploads. So whole file won't get buffered in WEB server at any point. As one can do with regular uploads like this:

    Using Command As SqlCommand = New SqlCommand(String.Concat("INSERT INTO Dokuments(DokumData...) values (@DokumData...)"), connection)

    'Other params

    Command.Parameters.Add("@DokumData", SqlDbType.Binary, -1).Value = oHttpPostedFile.InputStream 'oHttpPostedFile is from fileupload
    connection.Open()
    Command.ExecuteScalar()

    connection.Close()

  2. Answer
    Marin Bratanov
    Admin
    Marin Bratanov avatar
    4713 posts

    Posted 25 Sep 2018 Link to this post

    Terve Jukka,

    The Process method of a custom handler is only called when the entire file is available. Using chunks helps the server performance when large files are involved, as well as client performance by reducing the request sizes too. If you use chunks, you will be able to read the temporary file as a stream when saving to the database, and so it will never have to load into memory in full. This is possible only after a successful upload, however. In such a case you do not even have to use a custom handler, you can process the file as shown here: https://docs.telerik.com/devtools/aspnet-ajax/controls/asyncupload/how-to/how-to-manipulate-the-uploaded-files.

    You can use file streams for separate chunks with the Kendo Upload widget - it sends blobs to the service you have configured and leaves it up to you to handle them: https://docs.telerik.com/kendo-ui/controls/editors/upload/chunk-upload.


    Regards,
    Marin Bratanov
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. Jukka
    Jukka avatar
    2 posts
    Member since:
    Jan 2018

    Posted 25 Sep 2018 in reply to Marin Bratanov Link to this post

    Hi Marin,

    Thank you for your reply. I can manage with chunked upload and custom handler's Prosess method.

    It would be cool, if you could add the possibility to let the developer handle those chunks from postedfile's inputstream in future release of Telerik UI for ASP.NET AJAX. So that one can stream uploaded files directly from client to the database. I just don't want to mix Telerik UI and Kendo UI in my client's project.

     

    Regards,

    - Jukka

     

  4. Marin Bratanov
    Admin
    Marin Bratanov avatar
    4713 posts

    Posted 26 Sep 2018 Link to this post

    Hello Jukka,

    I'd suggest posting your feature request in our feedback portal (https://feedback.telerik.com/Project/108/Feedback/List/Feature%20Request) so you can explain how you would use it, how you would expect it to be exposed and/or configured, and what use cases you foresee in your implementation. This would help other people with a similar situation review and vote as well, and then if the idea gets sufficient traction with the community, our management will be better able to evaluate and plan it.

    On mixing the two control suites - there are a few controls in the UI for ASP.NET AJAX suite that are actually WebForms wrappers over Kendo UI widgets, and if they are present on the page script conflicts may arise, but if you don't use them on the same page there will be no issues. You can find a list in the following article: https://docs.telerik.com/devtools/aspnet-ajax/general-information/troubleshooting/general-troubleshooting#telerik-controls-integration-with-kendo-ui-widgets. Just leaving this information here in case it is useful for you and lets you make a better informed decision (for example, perhaps you could put the kendo upload in an <iframe>).


    Regards,
    Marin Bratanov
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top