3.1.3 File Attachment Data Format

The following example demonstrates the relationship between the Base64 encoded file attachment content and the file attachment structure.

Base64 encoded file attachment content:

 x0lGQRQAAAABAAAAAAAAAAMAAAAKAAAARgBpAGwAZQAxAC4AdAB4AHQAAABhYmM=

File attachment content (47 bytes with values in hexadecimal):

 c7 49 46 41 14 00 00 00 01 00 00 00 00 00 00 00 03 00 00 00 0a 00 00 00 46 00 69 00 6c 00 65 00 31 00 2e 00 74 00 78 00 74 00 00 00 61 62 63

The following table shows the relationship between bytes in the decoded file attachment content and fields in the file attachment structure.

Bytes

Field

Notes

c7

49

46

41

file attachment signature

(4 bytes)

Signature matches the file attachment signature specified in section 2.1.

14

00

00

00

header size

(4 bytes)

Specifies that the size of the header is 20 (14 in hexadecimal) bytes.

01

00

00

00

version information

(4 bytes)

Specifies that the version information is 1.

00

00

00

00

reserved space

(4 bytes)

Reserved space with all zeros.

03

00

00

00

file size

(4 bytes)

Specifies that the number of file bytes is 3 (see file bytes field later in this table).

0a

00

00

00

file name length

(4 bytes)

Specifies that the length of the file name is 10 (0a in hexadecimal). As specified in 2.1.3, the total number of bytes used to store the file name is 20 bytes. (2 bytes per character in the file name. See file name buffer fields later in this table.)

46

00

69

00

file name buffer

(variable)

First set of 2 UNICODE UTF-16 characters of the file name buffer. The first letter is "F" (the first 2 bytes maps to "F" in UNICODE UTF-16). The second letter is "i" (the last 2 bytes maps to "i" in UNICODE UTF-16).

6c

00

65

00

file name buffer (continued)

Second set of 2 UNICODE UTF-16 characters of the file name buffer. The first letter is "l" (the first 2 bytes maps to "l" in UNICODE UTF-16). The second letter is "e" (the last 2 bytes maps to "e" in UNICODE UTF-16).

31

00

2e

00

file name buffer (continued)

Third set of 2 UNICODE UTF-16 characters of the file name buffer. The first letter is "1" (the first 2 bytes maps to "1" in UNICODE UTF-16). The second letter is "." (the last 2 bytes maps to "." in UNICODE UTF-16).

74

00

78

00

file name buffer (continued)

Fourth set of 2 UNICODE UTF-16 characters of the file name buffer. The first letter is "t" (the first 2 bytes maps to "t" in UNICODE UTF-16). The second letter is "x" (the last 2 bytes maps to "x" in UNICODE UTF-16).

74

00

00

00

file name buffer (continued)

Fifth set of 2 UNICODE UTF-16 characters of the file name buffer. The first letter is "t" (the first 2 bytes maps to "t" in UNICODE UTF-16). The final two bytes in the file name buffer are zeros because they are the zero in the zero terminated string.

61

62

63

file bytes

(variable)

Given the file name of "File1.txt", it is known that the file is a text file. Therefore, this specifies that the contents of the file bytes is "abc".

By analyzing the bytes of the Base64 decoded file attachment content it can be determined that:

  1. File attachment signature (bytes 1-4)

  2. Header size is 20 bytes (bytes 5-8)

  3. Version information is 1 (bytes 9-12)

  4. Reserved space is 0 (bytes 13-16)

  5. File size is 3 bytes (bytes 17-20)

  6. File name length is 10 (bytes 21-24)

  7. File name buffer contains "File1.txt" with a terminating zero (bytes 25-44)

  8. File data contains "abc" (bytes 45-17)