Blog
/
Product

File Storage with the File field type

Published
December 13, 2021
Last updated
December 7, 2023
It’s hard to find a modern application that doesn’t need to store files. Now, every Gadget application can store and serve files in the cloud, with zero configuration.

From user profile images to invoice PDFs to cute dog pics, it’s hard to find a modern application that doesn’t need to store files. We’re excited to announce that as of today, every Gadget application can store and serve files in the cloud, with zero configuration. Gadget accepts uploads in a variety of formats, stores file contents securely in Google Cloud Storage, and serves files using a performant CDN.

Here’s how it works:

  • You add a new field to any model, including those from a Connection, with the File field type
  • You use your app’s API client, or a GraphQL call to upload a file as the value for this new field on a record
  • Your app’s API writes the file to a private, cloud storage bucket that we’ve setup for you
  • When you read the record, Gadget returns a URL to access the file securely

There’s no time spent setting up cloud buckets, configuring security rules, or dealing with cross origin headers -- just add a File field and you’re set to go.

The File field type supports validations just like any other field, so you can limit the size or nature of files your app will store. File fields can be edited or changed within effect code snippets along with the rest of the record as well. And finally, you can limit file access using the same role-based permission-ing system that handles access to other fields and records.

We’ve also tried to make it as easy as possible to write frontend code to create files in Gadget. You can submit files to your Gadget app’s API using base64 encoded strings, using multipart form requests from the browser, or using an existing URL to a file. And finally, Gadget supports direct upload to cloud storage, which gives a great user experience when uploading bigger files. Your generated Gadget API client already knows how to communicate with the Gadget API for all these methods, so uploading files works just the same as any other action.

You can see an example of a React application which uploads files to Gadget here and read the File field docs here.

Harry Brundage
Author
Reviewer
Try Gadget
See the difference a full-stack development platform can make.
Create app
No items found.

File Storage with the File field type

It’s hard to find a modern application that doesn’t need to store files. Now, every Gadget application can store and serve files in the cloud, with zero configuration.
Problem
Solution
Result

From user profile images to invoice PDFs to cute dog pics, it’s hard to find a modern application that doesn’t need to store files. We’re excited to announce that as of today, every Gadget application can store and serve files in the cloud, with zero configuration. Gadget accepts uploads in a variety of formats, stores file contents securely in Google Cloud Storage, and serves files using a performant CDN.

Here’s how it works:

  • You add a new field to any model, including those from a Connection, with the File field type
  • You use your app’s API client, or a GraphQL call to upload a file as the value for this new field on a record
  • Your app’s API writes the file to a private, cloud storage bucket that we’ve setup for you
  • When you read the record, Gadget returns a URL to access the file securely

There’s no time spent setting up cloud buckets, configuring security rules, or dealing with cross origin headers -- just add a File field and you’re set to go.

The File field type supports validations just like any other field, so you can limit the size or nature of files your app will store. File fields can be edited or changed within effect code snippets along with the rest of the record as well. And finally, you can limit file access using the same role-based permission-ing system that handles access to other fields and records.

We’ve also tried to make it as easy as possible to write frontend code to create files in Gadget. You can submit files to your Gadget app’s API using base64 encoded strings, using multipart form requests from the browser, or using an existing URL to a file. And finally, Gadget supports direct upload to cloud storage, which gives a great user experience when uploading bigger files. Your generated Gadget API client already knows how to communicate with the Gadget API for all these methods, so uploading files works just the same as any other action.

You can see an example of a React application which uploads files to Gadget here and read the File field docs here.

Interested in learning more about Gadget?

Join leading agencies making the switch to Gadget and experience the difference a full-stack platform can make.