Upload or Replace Media

Uploads a file the normal HTTP way. You may add headers to the request in order to provide some control to your media-file.

Bandwidth retains uploaded media for up to 48 hours.

Request URL


Basic Authentication

Bandwidth's messaging API leverages Basic Authentication with your API Token and API Secret. Read more about how Bandwidth secures endpoints in the Security & Credentials document.


Header Description Mandatory
Content-Length Indicates the size of the entity-body. Yes
Cache-Control General-header field is used to specify directives that MUST be obeyed by all caching mechanisms along the request/response chain. No
Content-Type The media type of the entity-body. Yes

Example 1 of 1: Upload an MP3 File

curl -X PUT \
    --url 'https://messaging.bandwidth.com/api/v2/users/{accountId}/media/{file.mp3}' \
    -H "Content-Type: audio/mpeg" \
    -u '{token}:{secret}' \
    --data-raw "@{/filepath/file.mp3}"
using ( FileStream fs = File.OpenRead("C:\\Path\\To\\File") )
    msgClient.UploadMedia(MSG_ACCOUNT_ID, mediaId, fs.Length, fs, "audio/wav");
f = File.open("some file", "rb")
file_content = f.read
messaging_client.upload_media(MESSAGING_ACCOUNT_ID, "mediaId", file_content.length.to_s, file_content, :content_type => "application/octet-stream", :cache_control => "no-cache")
f = open("some_file", "rb")
file_content = f.read()
messaging_client.upload_media(MESSAGING_ACCOUNT_ID, "mediaId", str(len(file_content)), body=file_content)

results matching ""

    No results matching ""