How to upload the image from the stream in WCF rest service

前端 未结 2 796
轻奢々
轻奢々 2021-01-17 01:07

I\'m trying to create the wcf service which will upload the files like pdf,doc,xls,images but pdf, txt files are uploading and opening properly but when i\'m trying to uploa

相关标签:
2条回答
  • 2021-01-17 01:47

    @mohammad check the below image how i'm trying to upload the image file how i'm trying to upload the image file

    Thanks

    0 讨论(0)
  • 2021-01-17 01:53

    try byte array instead of stream and wrapping the class like this:

    public class Input
    {
        [DataMember]
        public string fileName { get; set; }
        [DataMember]
        public byte[] fileContents { get; set; }
    }
    

    then simply write the file on disk like this:

    public string Upload(Input input)
    {
        File.WriteAllBytes(input.fileName, input.fileContents);
        return "OK";
    }
    
    0 讨论(0)
提交回复
热议问题