Filenames as metadata

My iOS app The Map uses what I think is a neat, but simple, system for hosting map data over FTP.

When I upload a map file to hosting server the only things I can rely on are the file’s name, data, and length. Extra file attributes can’t be relied upon.

The system consists of two parts: putting all required metadata in each file’s name, and a mechanism for generating the manifest from that metadata.

The filename

The filename is in this format:

[map name]-[timestamp]-[file size]-[file md5].osm.kater

here’s a concrete example:


The mechanism

Here’s the mechanism, written in pseudo (Swift) code:

var manifest: [String: String]

for (filePath, mapName, timestamp, fileSize, fileMd5, fileExtension) in sort( getFileList() )
   if fileExtension != "osm.kater" { continue }
   if fileSize != getFileSize(filePath) { continue }
   manifest[mapName] = filePath

print( asJSON( manifest ) )

The crux of this mechanism is the use of the file name to contain the file’s real file size. The file can be considered as uploaded only if the size on disk matches the size in the file name. It’s a simple, but critical check, especially as the maps can be huge (Germany is approximately 2GB).