File attachments

You can upload file attachments alongside error and crash reports to provide more context into a fault. There are various methods that can be used depending on how you integrate your applications. This article will provide an overview of the supported ways to upload file attachments.

C# and Unity

Backtrace supports crash and exception reporting from applications written in C# using the Unity SDK. Using our BacktraceReport object, you can specify a list of attachmentPaths to submit alongside the crash or exception report.

var report = new BacktraceReport(
exception: exception,
attributes: new Dictionary

HTTP submission

Most minidump generators have a built-in mechanism to upload minidumps and optional attachments to a specified HTTP(S) endpoint, but not all.

If your integration does not provide a way to upload minidump files and attachments, you can use our generic HTTP submission methods. You have two options:

Multipart POST

A submission where the test.json attachment is included with the initial crash submission. You can use the following cURL command:

curl -v -F "upload_file=@<Path_to_your_file>/test.json" -H "Accept: application/json" -F "attachment_test.json=@<Path_to_your_file>/test.json; type=application/json" "https://submit.backtrace.io/{your-subdomain}/{error-token}/json"

You’ll need to modify the following to successfully submit to your project:

  • {Path_to_your_file}: Location of file containing crash data to send.
  • {Path_to_your_attachment}: Location of file to be attached to the crash.
  • {your-subdomain}: First part of the URL used to access your project.
  • {error-token}: An error token for the project you want to submit crash data to.

Attach file to existing crash report

For this method, you’ll need the _rxid value assigned to a submitted crash report. This value will be returned after submitting a properly formatted request.

The first cURL command is the submission of the crash report.

curl -d <Path_to_your_file> -H "Accept: application/json"

"https://submit.backtrace.io/{your-subdomain}/{error-token}/json"

You’ll need to modify the following to successfully submit to your project:

  • {Path_to_your_file}: Location of file containing crash data to send.
  • {your-subdomain}: First part of the URL used to access your project.
  • {error-token}: An error token for the project you want to submit crash data to.

A properly formatted submission should return a response like:

{"response":"ok","_rxid":"56000000-8be7-5806-0000-000000000000"}

The second cURL command is the attachment of a file to the first command, described above.

curl -v --data-binary "upload_file=@<your_file_path>/test.json" -H "Expect: gzip" -H "Content-Type:application/json"

"https://submit.backtrace.io/{your-subdomain}/{error-token}/json/{_rxid}/{file-path}"

To attach a file to this object you’ll need to copy the _rxid returned in the previous command:

  • <_rxid>: Value returned from first HTTP submission.
  • <file-path>: Location of file to be attached to the crash.

A properly formatted upload submission should return a response like:

{"response":"ok","_rxid":"ce000000-0000-0000-0000-000000000000","attachment_name": "test.json","attachment_id": "28","object":"ce"}

The response should tell you that the file was attached to the specified object within your project. You’ll still get the 200/ok response, but the _rxid is going to look a bit different. As there was not a crash submitted, it won’t send a new unique id. This time it’s sending the attribute/error identifier within the debug view used to identify the specific crash report.

Breakpad

Breakpad is an open source library initially developed by Google for cross-platform C/C++ crash reporting. It’s a popular choice for Windows, Mac and Linux environments, including servers, desktop apps, and embedded devices. If you use Breakpad, you can leverage the library's files parameter to specify the set of file paths to be uploaded, as follows:

files["upload_file_minidump"] = descriptor.path();

files["attachment_log"] = "/var/log/myApp.log";

files["attachment_cpuinfo"] = "/proc/cpuinfo";

Crashpad

Crashpad is another open source library initially developed by Google as a successor to the Breakpad library. Backtrace has built and released a set of binaries of Crashpad for Windows (64 and 32 bit) that include an ability to upload file attachments. See http://get.backtrace.io/crashpad/builds/ to download the binaries for your OS.

To provide you with the ability to upload files, we have implemented a new handler to make file attachments as simple as setting up any other piece of metadata to come alongside the crash. Here’s what it looks like:

bool StartHandlerForBacktrace(
    const base::FilePath& handler,
    const base::FilePath& database,
    const base::FilePath& metrics_dir,
    const std::string& url,
    const std::map

This new handler is very similar to StartHandler, with the addition of the file_attachments parameter. file_attachments is a map of attachment name ⟶ path, allowing convenient inclusion of file attachments (i.e. the log file) with the crash dump.