Tech Blog

Creating an Ingest Form – the Easy Way

The Alma Digital Repository provides many ways to add files, and the documentation in the Developer Network includes examples of how to leverage ingest and deposit capabilities from external apps. In a recent Alma release, the General Configuration API has been enriched with additional fields that make easy work of creating an ingest form. In this post, we will show how to use the new fields to ingest a single file, and will show how the form can be used in a Cloud App to create new digital inventory.

Simple Ingest Form

The configuration API includes an option parameter, expand=ingest_form. When the parameter is provided, the API returns a new ingest_form section within the digital object. The ingest_form includes the required fields to create an ingest form, including a signed policy which authorizes the browser to add a file to the repository.

In the PHP file below, we do the following:

  1. Call the API with the new expand parameter
  2. Build a form using all of the fields in the ingest_form section, with the ingest_url field as the form action
  3. Add  Content-Type and Content-MD5 fields, which are populated using the script described below
  4. Add a file picker to select the file for upload

We also add a bit of JavaScript code which populates the Content-Type field with the type of the file, and calculates an MD-5 hash of the file using the Crypto-JS library. The MD-5 hash ensures the file is not corrupted when being uploaded to the repository.

That’s all there is to it- our simple form is now ready to upload a new file.

Add Digital Inventory – Cloud App

In this section we will use the form fields from the API to add digital inventory to Alma from a Cloud App. In a previous blog post, we saw that the steps to add digital inventory programmatically are as follows:

Our Cloud App builds a form on the fly to upload a generated file. The form is built using the values from the API. Then an HTTP POST is done using the Angular HttpClient, and progress events are tracked to provide feedback to the user while the file is uploading.

upload.service.tsView on Github

The full example is available in this repository.


These two examples show how the new fields in the general configuration API enable uploading files to Alma.