Declined
Last Updated: 29 May 2020 14:52 by ADMIN
Jukka
Created on: 02 Oct 2018 12:31
Category: AsyncUpload
Type: Feature Request
2
radasyncupload add SQL filestream support
I would be nice to gain more control over radasyncupload's upload behavior when using database as storage for uploaded files.

Consider this use case. You have file management web-app that uses SQL database as storage for uploaded files. In SQL database you use Filestream enabled table to store the uploaded file data. You like to allow your app users to upload multiple big files > 100 Mt at once. And you have limited disc space on your web server hosting your app. So you don't want to buffer those uploaded files on your web server in any point of the upload process.

To be able to do so radasyncupload needs to be able to stream uploaded files to the SQL database as straight as possible. Chunk by chunk. 

radasyncupload already has feature that allows you to use your own generic handler to handle some of the upload process. It just needs expose some of those events that happens before process-event (maybe ProcessRequest?). So developer can start handling the HttpPostedFile's InputStream at the begining of the upload and stream it directly to the database. Like one can do with the regular upload controls like so:

Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest

	Dim hpf As HttpPostedFile
	
	For i = 0 To context.Request.Files.Count - 1
	
		hpf = context.Request.Files.Item(i)
		
		...
		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 = hpf.InputStream
		connection.Open()
		Command.ExecuteScalar()
		connection.Close()
		
	Next

End Sub
2 comments
ADMIN
Peter Milchev
Posted on: 29 May 2020 14:52

Hello,

Saving the file directly to a SQL database, without accessing the file on a postback or disabling the chunk upload in order to avoid using a Temporary Folder brings a lot of complications and potential security and database compatibility issues.

If disabling the Chunk upload is an option for you, you can disable it and use the ProcessRequest event to process the file, which will not be saved in the Temporary folder:

That will actually limit most of the AsyncUpload functionalities.

That is why for such scenarios you can use custom code to send the file to a custom Handler/API to save it directly to the database.

One such option would be leveraging the chunk upload of the Kendo UI Upload widget and use the ChunkSave method to handler the separate chunks:

Regards,
Peter Milchev
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Adam
Posted on: 03 May 2019 20:33
Great suggestion.  It would be nice to avoid having to put the file(s) in a temporary location before it gets streamed into the DB.