Unable to cast object of type 'System.Web.HttpInputStream' to type 'System.IO.FileStream' MVC 3

后端 未结 5 845
無奈伤痛
無奈伤痛 2021-02-19 06:37

I have met an issue regarding the casting type from HttpInputStream to FileStream.

How I did ?

I have a HttpPostedFileBase object and I want to have

5条回答
  •  死守一世寂寞
    2021-02-19 07:17

    I used the following and it worked just fine for the same situation

    MemoryStream streamIWant = new MemoryStream();
    using (Stream mystream = (Stream)AmazonS3Service.GetObjectStream(AWSAlbumBucketName, ObjectId))                                                            
    {
        mystream.CopyTo(streamIWant);
    }
    return streamIWant;
    

    The GetObjectStream returns the same type of string mentioned in the question.

提交回复
热议问题