Starting March 27, 2025, we recommend using android-latest-release instead of aosp-main to build and contribute to AOSP. For more information, see Changes to AOSP.
         
       
     
  
  
  
  
  
    
    
      
    
    
      
      Stay organized with collections
    
    
      
      Save and categorize content based on your preferences.
    
  
  
    
  
  
  
  
    
  
  
    
    
  
  
HttpMultipartPost
  public
  
  
  
  class
  HttpMultipartPost
  
    extends Object
  
  
  
  
  
  
  
    
    | java.lang.Object | 
  
  
    
      | ↳ | com.android.tradefed.util.net.HttpMultipartPost | 
  
  
    
  Helper class for making multipart HTTP post requests. This class is used to upload files
 using multipart HTTP post (RFC 2388).
 To send multipart posts create this object passing it the url to send the requests to.
 Then set necessary parameters using the addParameter method and specify a file to upload
 using addFile method. After everything is set, send the request using the send method.
 Currently the implementation only supports 'text/plain' content types.
Summary
| Public methods | 
|---|
  
  
  
    | 
        
        
        
        
        
        void | 
      addParameter(String name, String value)
      Adds a string parameter to the request.
        
    
 | 
  
  
  
  
    | 
        
        
        
        
        
        void | 
      addTextFile(String name, String fileName, InputStream in)
      Add a file parameter to the request.
        
    
 | 
  
  
  
  
    | 
        
        
        
        
        
        void | 
      addTextFile(String name, File file)
      Add a file parameter to the request.
        
    
 | 
  
  
  
  
    | 
        
        
        
        
        
        void | 
      send()
      Sends the request to the server.
        
    
 | 
  
Public constructors
    HttpMultipartPost
    
public HttpMultipartPost (String url)
    
    
    
  
    
 
    HttpMultipartPost
    
public HttpMultipartPost (String url, 
                IHttpHelper httpHelper)
    
    
    
  
    
    | Parameters | 
|---|
      
        | url | String | 
      
        | httpHelper | IHttpHelper | 
    
 
Public methods
    addParameter
    
public void addParameter (String name, 
                String value)
    
    
    
  Adds a string parameter to the request.
    
    | Parameters | 
|---|
      
        | name | String: name of the parameter. | 
      
        | value | String: value of the parameter. | 
    
      
  
 
    addTextFile
    
public void addTextFile (String name, 
                String fileName, 
                InputStream in)
    
    
    
  Add a file parameter to the request. The contents of the file to upload
 will come from reading the input stream. Currently the implementation only
 supports 'text/plain' content type.
    
    | Parameters | 
|---|
      
        | name | String: name of the parameter. | 
      
        | fileName | String: file name to report for the data in the stream. | 
      
        | in | InputStream: stream whose contents are being uploaded. | 
    
      
  
 
    addTextFile
    
public void addTextFile (String name, 
                File file)
    
    
    
  Add a file parameter to the request. Opens the file, reads its contents
 and sends them as part of the request. Currently the implementation
 only supports 'text/plain' content type.
    
    | Parameters | 
|---|
      
        | name | String: name of the parameter. | 
      
        | file | File: file whose contents will be uploaded as part of the request. | 
    
      
  
 
    send
    
public void send ()
    
    
    
  Sends the request to the server.
      
  
 
 
 
  
  
 
  
    
    
      
    
    
  
       
    
    
  
  
  Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
  Last updated 2024-10-08 UTC.
  
  
  
    
      [[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-08 UTC."],[],[]]