How to manage file metadata?

Hi team!

I am trying to work out how to best manage file metadata that I need to display on screen.

In most cases, the “File” field type would suffice for the use case of attaching multiple images to a location on the “Locations” table however for each image I need to capture and show on screen the image license type and potential attribution (username/photographer name, etc).

In essence, I need a way to capture a File with:

{
    fileUrl,
    attribution,
    license,
}

where fileUrl is the existing set of “File” field type functionality, attribution is most likely just a “Text” field and license would be a dropdown “Switch” field with various license types.

Any advice on how to best create and store this structure?

From what I can see in the documentation on the “File” field type, there is no way to natively attach additional fields to the “File” type so I assume I would have to create a “Media” table which then has a set of fields of:

  • File (File, single file only)
  • Attribution (Text)
  • License (Switch, containing license types)

Then instead of my “Locations” table containing a “File” field, I would instead create a “Table” field which allows a 1 “Location” to many “Media” relationship?

Please let me know if I am approaching this the wrong way :slight_smile:

Looking forward to your feedback.

Hey @jannisg!

On any File record there is a field called meta that is a JSON field and can have any additional values stored.

mutation {
  fileUpdate(data: {
    id: "FILE_ID"
    meta: {
      someField1: 123
      someField2: "456"
    }
  }) {
    updatedAt
  }
}

When creating or updating any file, you can set this value to whatever you like.

If I understand correctly, I would suggest the following:

Media table

has_one File
has_one License
attribution Text
location [Smart Field -> Address OR JSON { lat: XX, long: XX }]

License Table

name Text
has_many Media