Files - Upload File

 This guide explains how to upload a file to EnterMediaDB using:

  • JSON REST API
  • EnterMediaDB API UI

Both methods perform the same operation.


1. Overview

The upload API allows you to:

  • Upload new files into EnterMediaDB
  • Store files in a specified directory (sourcepath)
  • Automatically generate asset metadata

2. API Endpoint

The API endpoint is the URL used to upload a file via the REST API.

Endpoint:

POST /assets/mediadb/services/module/asset/create

This endpoint:

  • Creates a new asset
  • Uploads the associated file

3. Required Parameters

The following parameters are required:

  • sourcepath: destination path where the file will be stored on the server
  • file: the file to upload

These parameters define where the file goes and what gets uploaded.


4. Upload File Using JSON REST API

Step 1: Create JSON Metadata File

Create a file (e.g., source.json) with:

{
  "sourcepath": "Clients/TK2/TK2024342/2020-6/"
}
 

Step 2: Send the Upload Request
curl -H "Content-Type: multipart/form-data" \
  -X POST http://entermediadb.org/assets/mediadb/services/module/asset/create \
  -b "entermedia.key=YOUR_SESSION_KEY; JSESSIONID=xxx" \
  -F "json=@source.json;type=application/json" \
  -F "file=@sample.jpg"
 

Notes
  • Replace YOUR_SESSION_KEY with your actual entermedia.key
  • Ensure your API session is initialized (see Authentication section)
  • The request must use multipart/form-data
  • The json field contains metadata
  • The file field contains the uploaded file

5. Upload File Using API Tool (UI)

You can upload files directly using the EnterMediaDB interface.

Steps
  1. Open the API UI

    Example:
    https://emedialibrary.org/mediadb

  2. Navigate to:
    Files → Upload File

  3. In the request editor, enter:
{
  "sourcepath": "${formattedmonth}/subpath/${filename}",
  "assettype": "photods"
}
 
  1. Click Choose File and select your file
  2. Click Execute

3.6 Response

A successful request returns:

  • status: "ok"
{
  "response": {
    "status": "ok",
    "id": "AXLIZAeT6Khr_XFrhdhk"
  },
  "data": {
    "id": "AXLIZAeT6Khr_XFrhdhk",
    "name": "source.gif",
    "sourcepath": "Clients/TK2/TK2024342/2020-6"
  }
}
 

6. What Happens After Upload

After a successful upload:

  • A new asset is created in EnterMediaDB
  • Metadata is automatically generated
  • The file becomes available for:
    • Search
    • Conversion
    • Download

7. Troubleshooting

1. Upload fails
  • Check that sourcepath is valid
  • Ensure the file exists and is accessible
  • Confirm request format is multipart/form-data

2. Unauthorized request
  • Ensure entermedia.key is included
  • Ensure session is initialized
  • Verify API permissions are enabled

3. File not appearing in UI
  • Refresh the interface
  • Verify correct sourcepath
  • Check user permissions