Accessing data of the current file in custom field

Hey ho.

I have a custom field which I want to use for files in blueprints like this:

title: My Blueprint
      label: My Field
      type: myfield

No problem so far.

I know that I can access the data of the current page in my field class, but can I also access the data of the current file?

I found a solution, but it feels a bit hacky …

class MyField extends InputField {

  public function file() {
    if (!empty(panel()->route->arguments[1])) {
      $fileName = panel()->route->arguments[1];
      return $this->page()->file($fileName);

    return NULL;


I have created a feature request for this.