Direct Single Upload via S3

Upload a media file that is on a local machine


The direct upload method is the simplest way to get a locally available, smaller (<100MB) file ingested into JW Player's platform. The process involves directly uploading the file to a provided link. Because of this, the direct upload method is not resumable, and network errors will require starting over.

📘

For Platform Management API v1 developers, use this article to upload your content.



Upload media

Use the following steps to upload your media:

  1. Make a POST /v2/sites/{site_id}/media call to create a new media object. Within the JSON body, set upload.method to direct and define the metadata of the media item. Refer to the POST /v2/sites/site_id/media/ reference for more information about acceptable metadata body parameters.

    The API call returns a response with the upload_link location.

    In the following sample, only the media item's metadata.title is defined.
curl -X POST https://api.jwplayer.com/v2/sites/{site_id}/media \
 -H 'Authorization: Bearer {v2_api_secret}' \
 -H 'Content-Type: application/json' \
 -d '{ "upload": { "method": "direct" }, "metadata": {"title": "My Uploaded Video"} }'
import requests

url_u = f"https://api.jwplayer.com/v2/sites/{site_id}/media"
payload_u = {
    "upload": {
        "method": "direct"
    },
    "metadata": {
        "title": "My Uploaded Video"
    }
}
headers_u = {
    "Accept":"application/json",
    "Content-Type":"application/json",
    "Authorization": f"Bearer {v2_api_secret}"
}

method_u = 'POST'
response = requests.request(method=method_u, url=url_u, headers=headers_u, json=payload_u)

  1. Upload the local media file to the upload_link location.

    If you included mime_type in the create media request, you must set the Content-Type header on the upload request to the exact same value. Similarly, if you exclude mime_type in the create media request, you must omit the Content-Type header in the upload request.
curl --upload-file {path_to_file} "{upload_link}"
curl --upload-file {path_to_file} "{upload_link}" -H 'Content-Type: {mime_type}'
upload_url = response.json()['upload_link']
requests.put(url=upload_url, data=open(file_path, 'r').read())

  1. After the uploading process has completed, make a GET /v2/sites/{site_id}/media/{media_id} call to retrieve the media transcoding status.
curl -X GET https://api.jwplayer.com/v2/sites/{site_id}/media/{media_id} \
 -H 'Authorization: Bearer {v2_api_secret}' \
 -H 'Content-Type: application/json'


Did this page help you?