uploadfile.do

APIs

The uploadfile.do call uploads a file to an existing build or creates a build. Veracode recommends that you use the uploadlargefile.do call to avoid timeout errors when uploading a large file.

Before using this API, Veracode strongly recommends that you read API Usage and Access Guidelines.
Before uploading additional files, ensure that:
  • An upload or prescan is not in progress.
  • The beginscan.do call is not in progress.
  • If you recently ran the beginscan.do call, you did not set auto_scan to true.

Since the uploadfile.do call creates a build, if one does not already exist or if the most recent build has a published static scan, you are not required to call createbuild.do. If the call creates a build, the build name is the date of the build with the scan type. For example, 03 Mar 2019 Static.

If you want to upload a file that does not have the same name as a previous file, you can use the save_as parameter to change the name, enabling flaw-matching with previously scanned files.

Resource URL

https://analysiscenter.veracode.com/api/5.0/uploadfile.do

Parameters

app_id Integer. Required.
file The file to upload. Required. The maximum file size is 2GB.
Requirements:
  • Set Content-Type: multipart/form-data
  • Open the file in binary mode.

If you see timeout errors during the upload, you can use the uploadlargefile.do call.

Note: You must enter the @ symbol before the entire pathname, including the specific filename.
sandbox_id Integer. Optional. Enter the ID of the sandbox to which you want to upload the file.
save_as String. Optional. Enter the new filename to give the uploaded file a unique name. The filename cannot begin or end with slashes or periods.

cURL Example

curl --compressed -u <VeracodeUsername>:<VeracodePassword> https://analysiscenter.veracode.com/api/5.0/uploadfile.do -F "app_id=<your app ID>" -F "file=@<yourfilename>" -F "save_as=oldfilename"

cURL Results

The uploadfile.do call returns the filelist XML document, which references the filelist.xsd. Additional filelist.xsd schema documentation is available. Use the XSD file to validate the XML data.

Java Example

This example uses the Veracode username and password:

java -jar vosp-api-wrappers-java-<version #>.jar -vuser <VeracodeUsername> -vpassword  <VeracodePassword> -action uploadfile -appid <app id> 
-filepath c:\Users\<Username>\MyApp-5.0.war

Java Results

The uploadfile.do call returns the filelist XML document, which references the filelist.xsd. Additional filelist.xsd schema documentation is available. Use the XSD file to validate the XML data. The following is an example of the returned XML:

 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<filelist xmlns="https://analysiscenter.veracode.com/schema/2.0/filelist" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" account_id=<account id> app_id=<app id> build_id=<build id> 
 filelist_version="1.1" xsi:schemaLocation="https://analysiscenter.veracode.com/schema/2.0/filelist https://analysiscenter.veracode.com/resource/2.0/filelist.xsd">

  <file file_id=<file id> file_name="MyApp-5.0.war" file_status="Uploaded"/>

</filelist>