求指导如何post带文件的表单?multipart/form-data

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

求指导如何post带文件的表单?multipart/form-data

taohuang
This post was updated on .
List<NVPair> headerList = new ArrayList<NVPair>()

headerList.add(new NVPair("Content-Type", "multipart/form-data; charset=utf-8"))

headers = headerList.toArray()

NVPair[] formdata() {
 
        return [
                new NVPair("A", "1"),
                new NVPair("B", "2")
        ];
    }
 
    @Test
    public void test1() {
 
        HTTPResponse result = request.POST(url, formdata(), headers, true)


比如传name='file',filename='upload.txt'