This is a migrated thread and some comments may be shown as answers.

byte[]

4 Answers 101 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Juan Puebla
Top achievements
Rank 1
Juan Puebla asked on 27 Aug 2009, 09:09 PM
I'm using UploadHandler to save files to a database. I commented base.ProcessStream and I add the following line:

byte

 

[] buffer = Convert.FromBase64String(Request.Form[RadUploadConstants.ParamNameData]);

 


To do this I cannot upload a file in chunks becuase then the buffer is only load with last chunk. Is there a way to use this but also Upload in chunks?

Thanks

Juan Puebla

4 Answers, 1 is accepted

Sort by
0
Accepted
Kiril Stanoev
Telerik team
answered on 28 Aug 2009, 11:17 AM
Hi Juan,

Please have a look at this KB Article and let me know how it works for you.

All the best,
Kiril Stanoev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Licenses
Top achievements
Rank 1
answered on 04 May 2010, 02:24 PM
Hello,

I have a question regarding the chunks and the byte[].
I believe you have to save each chunk seperately to the database. Am I correct?

Is there a way to collect each chunk in memory as a byte[] and when the last chunk is uploaded, the byte[] can be saved as a whole?

The reason is the following:
I want to upload a file (big file) and save it to the database in a Filestream column along with some additional metadata. The actions to save it all in the database should be in 1 call on the server so it can be placed in a transaction.
I think it is impossible to do this by overriding the savechunkdata?

Is there a workaround or am I missing something?

thanks in advance

Sodi We
0
Ivan
Telerik team
answered on 04 May 2010, 02:36 PM
Hi Sodi We,

You shoul override the SaveChunkData and inside it check when the last chunk is uploaded. After the last chunk is uploaded you can save the file in your data-base. Finally you can delete the file from the file-system. Your code shoul look something like:
 
public override bool SaveChunkData(string filePath...)
{
    bool result = base.SaveChunkData(filePath...);
    if (this.IsFinalFileRequest())
    {
        if (result)
        {
            // save file into your data-base
        }
        // delete the file from file system:
        this.RemoveFile(filePath);
    }
 
Please give it a try and let us know if you have more question.

Kind regards,
Ivan
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Mac P
Top achievements
Rank 1
answered on 02 Jun 2010, 10:28 PM
Sodi,

You wont gain any performance improvement by uploading entire byte[] to database. I just implemented this feature and once file is uploaded to temp directory the silver light control pauses till the database insertion is complete. For files that i uploaded (around 42MB) it took around 35 seconds for single file upload to database after it read from temp folder.

In contrast i am evaluating a way where i can find a way to insert chunks directly into database (sql server 2008 R2 with filestream)
without any fragmentation and performance issues.

Regards
Mac
Tags
Upload
Asked by
Juan Puebla
Top achievements
Rank 1
Answers by
Kiril Stanoev
Telerik team
Licenses
Top achievements
Rank 1
Ivan
Telerik team
Mac P
Top achievements
Rank 1
Share this question
or