zoukankan      html  css  js  c++  java
  • Web Api 如何做上传文件的单元测试

    代码如下:

                //--------上传------------
                HttpClient client = new HttpClient();
                #region
                MultipartFormDataContent form = new MultipartFormDataContent();
                StreamContent fileContent = new StreamContent(File.OpenRead(@"D:uni-all-resourcesCloudShopSourceDevelopmentUni2uni.iShopUni2uni.iShop.WebApiUploadAudioios_2.pcm"));
                fileContent.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
                fileContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data");
                fileContent.Headers.ContentDisposition.FileName = "ios_2.pcm";
                form.Add(fileContent);
                #endregion
    
                HttpResponseMessage res = client.PostAsync("http://app.uni2uni.com/api/Audio/UploadAudioResponseMessage", form).Result;
                var uploadModel = res.Content.ReadAsStringAsync().Result;
    在寂寞的日子里沉淀自己,在程序的日子里找到自己,我为梦想而坚持!

    如果对你有重要帮助,可以打赏一下!


  • 相关阅读:
    饿了么 PostgreSQL 优化之旅
    kubernetes 滚动更新发布及回滚
    kubernetes yaml
    mongodb安装
    node.js安装
    linux输出换行
    把token放入请求头
    $.ajaxSetup
    js前端读取文件内容
    v-echarts安装
  • 原文地址:https://www.cnblogs.com/Kummy/p/3688147.html
Copyright © 2011-2022 走看看