File uploaded with zero bytes

When i am executing    UploadedFiles = await fileuploader.GetFilesDataAsync(); this line of code before 

await fileuploader.UploadAsync(); // Upload the selected file manually then my uploaded files shows zero bytes means empty files


if i remove this line  UploadedFiles = await fileuploader.GetFilesDataAsync(); then every this works fine but i want files uploaded list to save in database

here is my code


<SfUploader @ref="fileuploader" ID="UploadFiles" SequentialUpload="true" AllowedExtensions=".txt,.jpg,.jpeg,.png,.doc,.docx,.xls,.xlsx,.zip,.pdf,.PDF" AllowMultiple="true" AutoUpload="false">

                        <UploaderEvents ValueChange="OnChange"></UploaderEvents>

                    </SfUploader>



//C# Code

 SfUploader? fileuploader = null;


  private async Task SaveSupportTicket()

{

  if (fileuploader != null)

                        {

                            UploadedFiles = await fileuploader.GetFilesDataAsync();


                            foreach (var upfile in UploadedFiles)

                            {

                                attachments.Add(upfile.Name);

                            }


                            supportTicket.AttachmentPath = String.Join(",", attachments.ToArray());

                        }

}


private void OnChange(UploadChangeEventArgs args)

        {

            try

            {

                foreach (var file in args.Files)

                {

                    var path = Path.GetFullPath("wwwroot\\Attachments\\") + Path.GetFileNameWithoutExtension(file.FileInfo.Name) + "_" + selectedClient.CustomerID + "_" + (savedSupportTicket!=null ? savedSupportTicket.TicketNo : string.Empty) + Path.GetExtension(file.FileInfo.Name);

                    FileStream filestream = new FileStream(path, FileMode.Create, FileAccess.Write);

                    file.Stream.WriteTo(filestream);

                    filestream.Close();

                    file.Stream.Close();

                }

            }

            catch (Exception)

            {


                throw;

            }


        }



6 Replies

SP Sureshkumar P Syncfusion Team September 12, 2022 11:58 AM UTC

Hi Dhiraj,

We have validated the requirement, when we are using the GetFilesDataAsync method we got the uploader selected file details. We have attached the validated sample in the attachment.

Find the screenshot here:

If still, you have faced the same issue, then please replicate the reported issue on the attached sample and revert us with a detailed issue replication procedure. These details will help us to provide an exact solution as earlier as possible.

Regards,

Sureshkumar P


Attachment: UploaderServer_8d020563.zip


DD Dhiraj Dewani September 12, 2022 03:29 PM UTC

I dont have issue in GetFilesDataAsync i have issue in upload files if use this GetFilesDataAsync and after that i upload files then files do not upload properly it shows zero bytes in files


Like this below code


 UploadedFiles = await fileuploader.GetFilesDataAsync(); //If i comment this code then all working fine and if i dont comment it then files uploaded with zero bytes


 await fileuploader.UploadAsync(); // Upload the selected file manually



DD Dhiraj Dewani replied to Sureshkumar P September 12, 2022 03:38 PM UTC

Please find the Updated Code in attachment


Attachment: UploaderServer_UpdatedCode_4024ed68.zip


SP Sureshkumar P Syncfusion Team September 13, 2022 03:55 AM UTC

Hi Dhiraj,

We have validated the modified code sample; we have faced no issues from our end.

Please find the screenshot for manual uploading the details of the selected file:

File uploading size

Regards,

Sureshkumar P



DD Dhiraj Dewani September 13, 2022 08:49 AM UTC

You are not understanding my issue i am not talking about code in code debug all is showing correct file name and file size after uploading files to specific folder it shows zero bytes in file explorer.


see screenshot in attachment


Attachment: Screenshot_20220913_141820_4605d773.zip


SP Sureshkumar P Syncfusion Team September 15, 2022 10:33 AM UTC

Hi Dhiraj,

We have updated the response in an incident under your account for this requirement # 405499. Please follow the ticket for further technical assistance.

Regards,

Sureshkumar P


Loader.
Up arrow icon