标签: multipart

我如何在颤振中以多部分请求发送地图对象

在这里,我尝试在多部分请求中发送对象映射,但我的请求是字符串,而不是 JSON 格式,请建议我执行正确的请求。提前致谢。

我已经尝试过多部分请求,但我的请求应该采用正确的形式。

var getApiUrl = 'http://malik-env-test.ap-south-1.elasticbeanstalk.com/webapi/post/create';

  Map userData = {

    "creator": {
      "creatorId": "298",
      "createDate": "2018-12-21 20:44:45.8"
    },
    "info": "$campusInfo",
    "title": "$eventName",
    "postCampusId": "5642"

  };

Run Code Online (Sandbox Code Playgroud)
Uri uri = Uri.parse(getApiUrl);
   http.MultipartRequest request = new http.MultipartRequest('POST', uri);
   request.fields['creator'] = userData['creator'];
   request.fields['info'] = '$campusInfo';
   request.fields['title'] = '$eventName';
   request.fields['postCampusId'] = '5642';
   request.files.add(await http.MultipartFile.fromPath('image_file1', imagePath, contentType: new MediaType('application', 'x-tar')));
//   var body = json.encode(request);
   print(request);
   http.StreamedResponse response = await request.send();
   String jsonData = response.toString();
   print(jsonData);ddd
Run Code Online (Sandbox Code Playgroud)

multipart dart flutter

1
推荐指数
1
解决办法
4902
查看次数

使用WebApi MultipartFormDataStreamProvider在文件上载后无法更改文件名

我使用WebApi上传文件,但是当我运行时

request.Content.ReadAsMultipartAsync(provider)
Run Code Online (Sandbox Code Playgroud)

文件已上传,但其文件名已完全更改.我读过一些关于它的说法是出于安全原因而自动制作的.无论如何,我想用真实的文件名存储文件.知道怎么做吗?

file-upload multipartform-data multipart asp.net-web-api

0
推荐指数
1
解决办法
1714
查看次数

使用Vertx.io框架为多部件文件上载编写后API

我正在使用vertx.io编写用于多部分文件上载的代码.

在Spring启动时,我的代码如下.我想在vertex.io中写类似的东西

@RequestMapping(value = "/upload", headers=("content-type=multipart/*") ,method = RequestMethod.POST)
public ImportExportResponse upload(@RequestParam("file") MultipartFile inputFile){
    log.info(" upload service method starts  ");
    ImportExportResponse response = new ImportExportResponse();
    FileOutputStream fileOutputStream=null;
    try{
        File outputFile = new File(FILE_LOCATION+inputFile.getOriginalFilename());
        fileOutputStream = new FileOutputStream(outputFile);
        fileOutputStream.write(inputFile.getBytes());   
        fileOutputStream.close();

        response.setStatus(ImportExportConstants.ResponseStatus.SUCCESS.name());
        response.setErrorMessage(EMPTY);

    }catch (Exception e) {
        log.error("Exception while upload the file . "+e.getMessage());
        response.setStatus(ImportExportConstants.ResponseStatus.ERROR.name());
        response.setErrorMessage(errorMap.get(SYSTEM_ERROR_CODE));          
    }
    log.info(" upload service method ends. file is copied to a temp folder ");
    return response;
}
Run Code Online (Sandbox Code Playgroud)

java multipart vert.x

0
推荐指数
1
解决办法
4597
查看次数

如何从 http.Request 的响应中读取文件内容

我使用下面的代码向 http 服务器发送请求。

服务器发送包含这些 http 标头的响应

Content-Disposition:[attachment;filename=somefilename.csv] 
Content-Type:[text/csv; charset=UTF-8]
Run Code Online (Sandbox Code Playgroud)

我如何继续检索响应所附文件的内容?

baseUrl := "Some url that i call to fetch csv file"

client := http.Client{}

resp, _ := client.Get(baseUrl)
defer resp.Body.Close()

fmt.Println(resp)

// &{200 OK 200 HTTP/2.0 2 0 map[Content-Disposition:[attachment;filename=somefilename.csv] Content-Type:[text/csv; charset=UTF-8] Date:[Mon, 30 Sep 2019 09:54:08 GMT] Server:[Jetty(9.2.z-SNAPSHOT)] Vary:[Accept]] {0xc000530280} -1 [] false false map[] 0xc000156200 0xc0000c26e0}
Run Code Online (Sandbox Code Playgroud)

multipart go content-disposition

0
推荐指数
1
解决办法
1万
查看次数