Upload File V1

This document outlines the process of uploading media files to the Release Candidate (RC) environment via the /api/media/upload endpoint. This procedure is crucial for transferring media assets, such as images and videos, to the server for storage and processing.

Environments

Allowed Files

  • VIDEO mp4

  • VIDEO mov

  • VIDEO avi

  • VIDEO mkv

  • VIDEO flv

  • VIDEO wmv

  • IMAGE jpg

  • IMAGE jpeg

  • IMAGE png

  • IMAGE svg

  • AUDIO mp3

  • AUDIO wav

  • AUDIO aac

  • AUDIO flac

Prerequisites

  • Access Token: You must obtain a valid access token by authenticating with the service.

  • Authentication API Key: An API key is required to authenticate the request.

  • Media File: The file to be uploaded.

  • Data Payload: A base64 encoded JSON string containing metadata about the file, including tags.

Upload File Endpoint

This endpoint allows you to upload a media file to the respective environment.

End point - api/media/upload

Method - POST

Header -

  1. Authorization: Bearer {{YOUR-ACCESS-TOKEN}}

Note Token life time is 1 week.

Form Data -

  1. file: The media file to be uploaded.

  2. data: A base64 encoded string containing the metadata for the upload. The structure of the data is as follows:

{
    "tags": {
        "tag1": "value1",
        "tag2": "value2"
    }
}

curl -

curl --location '{{BASE-URL}}/api/media/upload' \
--header 'Authorization: Bearer {{YOUR-ACCESS-TOKEN}}' \
--form 'file=@{{FILE}}' \
--form 'data={{DATA}}'

Example curl Command

curl --location 'https://sdk-mobile-api.truvideo.com:443/api/media/upload' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJDb3ggQXV0byIsImFjY291bnRJZCI6ImM0ZTRiOTA2LWUxMDktNDZiNC1iMThhLTQ0NmViZGNkNzI2ZSIsInN1YkFjY291bnRFeHRlcm5hbElkIjoiYzRlNGI5MDYtZTEwOS00NmI0LWIxOGEtNDQ2ZWJkY2Q3MjZlIiwic3ViQWNjb3VudElkIjoiYjQ0Njg5ZTctMzJmNS0xMWVmLWIyMzQtMDY2MGMzNzA2NjM3IiwiYXV0aCI6IkJBQ0tPRkZJQ0UiLCJleHAiOjE3MjY3NzczNjAsImlhdCI6MTcyNjY5MDk2MH0.3VzD3i7OhNsWSp3YrYccDoIQKQqauVmRDzY4fGV4_cg' \
--form 'file=@"postman-cloud:///1ef54350-aa72-4220-935e-98e7218d4654"' \
--form 'data="eyJ0YWdzIjogeyJERUFMRVJfQ09ERSI6ICJYVEdJUkNYWDEiLCAiQ09NUEFOWV9TVE9SRSI6ICIxMTEiLCAiUk9fTlVNQkVSIjogIjEyMzQ1Njc4IiwgIlZJTiI6ICI1WFlLVENBNjdGRzU3MTgwMiIsICJFWFRfQ1VTVF9JRCI6ICJjdXN0b21lci1pZCIsICJDT05GSVJNQVRJT05fSUQiOiAiWDExMzMyNDMyIiwgIlVQTE9BREVEX0JZX0lEIjogImRsLWFkdmlzb3IiLCAiVVBMT0FERURfQllfTkFNRSI6ICJEYXZpZCBMZWUiLCAiU09VUkNFX0FQUCI6ICJUV1QifX0="'

Response -

{
  "id": "cc655259-13b8-4392-a338-7e7578ee5642",
  "url": "https://sdkmobile-5bb84749-4d69-4d3e-9155-1e0f86651785.s3.us-west-2.amazonaws.com/media/maxresdefault (1).jpg",
  "tags": {
      "tag1": "value1",
      "tag2": "value2"
  },
  "type": "IMAGE",
  "createdDate": "2024-08-21T17:34:10Z",
  "title": "maxresdefault (1).jpg"
}

Params:

BASE-URL:


YOUR-ACCESS-TOKEN:

Access token provided by the endpoint mentioned on this documentation: [SDK Mobile] - Generate an API Token


FILE: This represents the media file (e.g., image, video, or document) that you want to upload. The path provided after the @ symbol should point to the file on your local machine or a specific file source. The format could vary depending on the type of file you are uploading. Ensure that the file is correctly referenced and accessible during the upload.

Example:

--form 'file=@/path/to/your/file.png'


DATA: This is a JSON-encoded as Base 64 string that contains additional metadata related to the file you are uploading. The structure of this JSON should include specific fields as required by the API, such as identifiers, tags, or other related information. Make sure the data is formatted as valid JSON, enclosed in double quotes when passed in the curl command.

This should be mandatory.

{ 
    "tags": { 
        "tag1": "value1", 
        "tag2": "value2" 
    }, 
    "duration": 120, //media duration in seconds 
    "includeInReport":true, 
    "isLibrary": true
}

duration (INTEGER): This field represents the media duration if it’s an AUDIO or VIDEO.

includeInReport (BOOLEAN): This field determines whether the uploaded media file should be included in the reports. It accepts the values true or false:

  • When set to true, the uploaded file will be included in the reports.

  • When set to false, the file will not be included in any reporting.

This field allows for flexibility in how the uploaded media is handled, depending on whether it is necessary to track or document it within the reporting system.

Example:

  • includeInReport=true will include the file in the report.

  • includeInReport=false will exclude the file from the report.

Last updated

Was this helpful?