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

is UploadedFile.SaveAs asynchronous?

4 Answers 58 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 17 Dec 2014, 01:42 AM
is UploadedFile.SaveAs asynchronous?

4 Answers, 1 is accepted

Sort by
0
Nencho
Telerik team
answered on 19 Dec 2014, 10:55 AM
Hello Alex,

The SaveAs method does not work asynchronously as the files are saved one by one.

Regards,
Nencho
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
swapnil
Top achievements
Rank 1
Iron
answered on 01 Feb 2019, 11:42 PM
I do UploadedFile.SaveAs(path) it saves file to disk successfully, this uploadedFile has one property InputStream , this inputstream becomes null as soon as .SaveAs method is completed. i want to use this inputstream after SaveAs method is executed. How i can achieve this ?
0
swapnil
Top achievements
Rank 1
Iron
answered on 01 Feb 2019, 11:56 PM
I do UploadedFile.SaveAs(path) it saves file to disk successfully, this uploadedFile has one property InputStream , this inputstream becomes null as soon as .SaveAs method is completed. i want to use this inputstream after SaveAs method is executed. How i can achieve this ?
public void Upload(UploadedFile file, string entityValue, string path, string domain, string org, string repNum, string entityType)
        {
               file.SaveAs(path); // This save file to local disk successfully
// After above line executes file.inputStrream becomes null and my obj.Upload method fails, how to fix this ?
                
                obj.Upload(file, entityValue, path, domain, org, repNum, entityType);
            

        }
0
Marin Bratanov
Telerik team
answered on 04 Feb 2019, 04:25 PM
Hello Swapnil,

You need to open a new stream from the new file you just created, the old file (in the temporary folder) is now deleted (that's what file.SaveAs() does) and so its stream should be expected to be null as it does not exist anymore.

An alternative is to use the stream to do the desired operation (e.g., write the files somewhere else, like in a database) and only then call .SaveAs().


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.
Tags
AsyncUpload
Asked by
Alex
Top achievements
Rank 1
Answers by
Nencho
Telerik team
swapnil
Top achievements
Rank 1
Iron
Marin Bratanov
Telerik team
Share this question
or