Files

This guide describes adding different file formats such as PDF, ZIP, GIF, and more to your web application using Prepr.

Introduction

Prepr allows you to add several file formats to a web application. You can use popular file types like PDF and ZIP, for example, to publish a Press kit, Terms of use, or any other document you want your website visitors to download. Besides, you can use the SVG and GIF graphics as a File asset in Prepr.

To add a file to a web application, you need to complete the following steps:

  1. First, allow using assets in a model.
  2. Next, add a file to a content item.
  3. Finally, retrieve a file using the API.

See the detailed instructions below.

⚠️

This guide assumes you have already set up a content model. If not, we recommend starting with the following steps:

Step 1: Add an Assets field to your model

To use assets in your content items, you must first add the Assets field to a content model as follows:

  1. Click the Schema tab to open the Schema Editor.
  2. Click on a model to open its details.
  3. Click or drag the Assets field from the list of field types into your model.

Add Assets field

  1. Fill in the Assets field settings, then click Save to confirm. For more information, check out the Field types guide.

Fill in Assets field settings

⚠️

Make sure to select the File asset type in the General tab to allow adding files to this field.

In the Settings tab, you can also enable the Caption and Alignment features to configure your file in the Prepr Editor interface. For more information, see the Add a file to a content item step.

Once done, you can add a file to your content item.

Step 2: Add a file to a content item

Now that you have allowed using assets in a model, you can add a file to your content item as follows:

  1. Navigate to the Content tab. You can either create a new content item or use an existing one.

  2. On the Content item page, go to the media placeholder and click the icon.

Add asset to a content item

  1. Select one or multiple images from the Media Library or upload new ones.

  2. Click Add x items to confirm.

Select asset

Optionally, you can edit a file in the Prepr Editor interface as follows:

On the Content item page, hover over a file and click the icon in the top right corner, then select the needed action.

Configure asset

⚠️

These features are only available if enabled in the Assets field settings.

Once done, proceed to the next step.

Step 3: Retrieve a file using the API

Once you have completed the previous steps, you can retrieve your file using the API.

Use the following snippets as a starting point to retrieve an identifier, a URL and the type of your file. You may want to add or remove arguments according to your desired set-up. For more information, see the GraphQL API reference.

query {
  Blog (id: "bb6e51df-94bb-4708-8cf8-40229058a2ab") {
    media {
      _id
      url
      mime_type
    }
  }
}

Please check out the Connecting front-end apps guide to learn more about retrieving content in a specific front-end framework.

That's it. Once you publish your content item, your file becomes available in your web application for download.

Want to learn more?

Check out the following guides to learn how to add other asset types to your web application:

Was this article helpful?

We’d love to learn from your feedback