byte[]

5 posts, 1 answers
  1. Juan Puebla
    Juan Puebla avatar
    3 posts
    Member since:
    Aug 2009

    Posted 27 Aug 2009 Link to this post

    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
  2. Answer
    Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1512 posts

    Posted 28 Aug 2009 Link to this post

    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.
  3. DevCraft banner
  4. Sodi We
    Sodi We avatar
    160 posts
    Member since:
    Apr 2010

    Posted 04 May 2010 Link to this post

    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
  5. Ivan
    Admin
    Ivan avatar
    519 posts

    Posted 04 May 2010 Link to this post

    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.
  6. Mac P
    Mac P avatar
    84 posts
    Member since:
    Mar 2010

    Posted 02 Jun 2010 Link to this post

    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
Back to Top
DevCraft banner