Attachments

Files can be attached visually by users or programmatically by code. You can instruct the SDK to quietly attach any file to a report. The files you attach are not visible to the user in the SDK.

Introduction

Send yourself XMPP logs, a user's profile photo, or whatever helps you debug issues faster. You will see these files in the center of your web Dashboard along with files the user maybe attached themselves.

Attachments screen

Methods

You can quietly attach files by using any of the methods described below.

Setting a custom filename and adding data

ShakeFile can be initialized with a filename (String) and data (NSData / Data). As custom data is provided, the file name cannot be automatically detected so it's mandatory:

AppDelegate.swift
let fileName: String = ...
let logData: Data = ...
Shake.onPrepareReportData = {
var attachedFiles = [ShakeFile]()
let attachedFile = ShakeFile(name: fileName, data: fileData)
attachedFiles.append(attachedFile)
return attachedFiles
}

Setting a custom filename and then attaching a file

ShakeFile can also be initialized with a desired filename (String) and a local url (NSURL) to your file:

AppDelegate.swift
let fileName: String = ...
let fileUrl: URL = ...
Shake.onPrepareReportData = {
var attachedFiles = [ShakeFile]()
if let attachedFile = ShakeFile(name: fileName, fileUrl: fileUrl) {
attachedFiles.append(attachedFile)
}
return attachedFiles
}

Just attaching a file

Or, you can initialize ShakeFile only with a local file url (NSURL), and the file name shown on the web Dashboard will be determined automatically from the passed file's URL:

AppDelegate.swift
let fileUrl: URL = ...
Shake.onPrepareReportData = {
var attachedFiles = [ShakeFile]()
if let attachedFile = ShakeFile(fileUrl: fileUrl) {
attachedFiles.append(attachedFile)
}
return attachedFiles
}

Limitations

The maximum number of attached files per bug is 1 for Free workspaces and 10 for Premium ones. If more files are attached, the SDK will successfully upload only some of them.

The maximum allowed individual size for any of those files is 10 MB. If you attach a file that's larger than that it won't be uploaded with the report.